pub enum GunError {
InvalidData(String),
Storage(Error),
Serialization(Error),
Network(String),
InvalidSoul(String),
NodeNotFound,
Io(Error),
UrlParseError(ParseError),
WebRTC(String),
Crypto(String),
}Expand description
Main error type for all Gun operations
All operations in Gun return GunResult<T> which is Result<T, GunError>.
This enum covers all possible error conditions that can occur.
§Error Variants
InvalidData(String): Data format is invalid or doesn’t match expected structureStorage(#[from] sled::Error): Storage operation failed (disk full, corruption, etc.)Serialization(#[from] serde_json::Error): JSON serialization/deserialization failedNetwork(String): Network operation failed (connection lost, timeout, etc.)InvalidSoul(String): Soul (node ID) format is invalidNodeNotFound: Requested node doesn’t exist in the graphIo(#[from] std::io::Error): I/O operation failed (file read/write, etc.)UrlParseError(#[from] url::ParseError): URL parsing failed (invalid peer URL)WebRTC(String): WebRTC operation failed (connection, signaling, etc.)Crypto(String): Cryptographic operation failed (encryption, signing, etc.)
§Error Handling
All errors implement std::error::Error and can be:
- Converted to strings with
to_string()orDisplaytrait - Used with
?operator for error propagation - Matched with pattern matching
§Example
use gun::{Gun, GunError};
use serde_json::json;
let gun = Gun::new();
// Operations return GunResult
let result = gun.get("test").put(json!({"data": 42})).await;
match result {
Ok(chain) => println!("Success: {:?}", chain),
Err(GunError::Storage(e)) => eprintln!("Storage error: {}", e),
Err(GunError::Network(msg)) => eprintln!("Network error: {}", msg),
Err(e) => eprintln!("Other error: {}", e),
}Variants§
InvalidData(String)
Invalid data format or structure
Storage(Error)
Storage operation failed (from sled database)
Serialization(Error)
JSON serialization/deserialization failed
Network(String)
Network operation failed (connection, timeout, etc.)
InvalidSoul(String)
Invalid soul (node ID) format
NodeNotFound
Requested node not found in graph
Io(Error)
I/O operation failed (file operations, etc.)
UrlParseError(ParseError)
URL parsing failed (invalid peer URL format)
WebRTC(String)
WebRTC operation failed (connection, signaling, etc.)
Crypto(String)
Cryptographic operation failed (encryption, signing, etc.)
Trait Implementations§
Source§impl Error for GunError
impl Error for GunError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<ParseError> for GunError
impl From<ParseError> for GunError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for GunError
impl !RefUnwindSafe for GunError
impl Send for GunError
impl Sync for GunError
impl Unpin for GunError
impl !UnwindSafe for GunError
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more