23 lines
644 B
Rust
23 lines
644 B
Rust
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum Error {
|
|
#[error("Failed to parse osc address")]
|
|
AddressParseError(String),
|
|
}
|
|
|
|
pub trait AddressParseResult<T> {
|
|
fn address_part_result(self, context: &'static str) -> Result<T>;
|
|
}
|
|
|
|
impl<T> AddressParseResult<T> for std::result::Result<T, std::num::ParseIntError> {
|
|
fn address_part_result(self, context: &'static str) -> Result<T> {
|
|
self.map_err(|e| {
|
|
Error::AddressParseError(format!(
|
|
"failed to parse number in address part {}: {}",
|
|
context, e
|
|
))
|
|
})
|
|
}
|
|
}
|