pub type ProtocolResult<T> = Result<T, ProtocolError>;Expand description
Result type alias for protocol operations.
§Examples
use chie_shared::{ProtocolResult, ProtocolError};
fn fetch_content(cid: &str) -> ProtocolResult<Vec<u8>> {
if cid.is_empty() {
return Err(ProtocolError::ContentNotFound("empty CID".to_string()));
}
Ok(vec![1, 2, 3, 4])
}
// Using the result
match fetch_content("QmTest") {
Ok(data) => assert_eq!(data.len(), 4),
Err(e) => panic!("Unexpected error: {}", e),
}
// Error case
assert!(fetch_content("").is_err());Aliased Type§
pub enum ProtocolResult<T> {
Ok(T),
Err(ProtocolError),
}