pub enum SyncError {
Transport(String),
Handshake(String),
Serialization(String),
Timeout,
ConnectionLost,
ProtocolVersion {
local: u32,
remote: u32,
},
WireFormatMismatch {
expected: u8,
got: Option<u8>,
},
InvalidPayload(String),
CursorNotFound {
instance: InstanceId,
},
Shutdown,
}sync only.Expand description
Errors specific to the sync protocol.
These are wrapped into crate::PulseDBError::Sync when propagated
through the public API.
Variants§
Transport(String)
Transport-level failure (network I/O, connection refused, etc.).
Handshake(String)
Handshake was rejected by the remote peer.
Serialization(String)
Failed to serialize or deserialize a sync message.
Timeout
Operation timed out waiting for a response.
ConnectionLost
Connection to the remote peer was lost.
ProtocolVersion
Protocol version mismatch between peers.
WireFormatMismatch
Wire-format preamble mismatch — caught by raw-byte inspection of the 3-byte preamble before any deserialize, so a serializer mismatch (e.g. a bincode-era peer vs a postcard-era peer) fails loud with a typed error instead of yielding garbage through the decoder.
This is distinct from SyncError::ProtocolVersion: that variant is
protocol-semantics (negotiated in-band after a successful decode);
this variant is wire-format (the bytes can’t be trusted to decode at
all). Two failure shapes feed it:
- bad magic (
got == None): the leading bytes are not a PulseDB sync preamble at all (truncated body, a non-PulseDB POST, or a pre-4.0 no-preamble peer’s body) — reported withgot: None. - wrong version (
got == Some(v)): a valid magic but awire_format_versionbyte this peer does not speak.
Fields
InvalidPayload(String)
Received an invalid or unrecognized payload.
CursorNotFound
No cursor found for the specified peer instance.
Fields
instance: InstanceIdThe peer instance whose cursor was not found.
Shutdown
The sync system is shutting down.
Implementations§
Source§impl SyncError
impl SyncError
Sourcepub fn transport(msg: impl Into<String>) -> Self
pub fn transport(msg: impl Into<String>) -> Self
Creates a transport error with the given message.
Sourcepub fn handshake(msg: impl Into<String>) -> Self
pub fn handshake(msg: impl Into<String>) -> Self
Creates a handshake error with the given message.
Sourcepub fn serialization(msg: impl Into<String>) -> Self
pub fn serialization(msg: impl Into<String>) -> Self
Creates a serialization error with the given message.
Sourcepub fn invalid_payload(msg: impl Into<String>) -> Self
pub fn invalid_payload(msg: impl Into<String>) -> Self
Creates an invalid payload error with the given message.
Sourcepub fn wire_format_bad_magic(expected: u8) -> Self
pub fn wire_format_bad_magic(expected: u8) -> Self
Creates a wire-format mismatch for a bad / absent magic preamble.
Used when the leading bytes are not a recognizable PulseDB sync preamble (truncated body, wrong magic, or a pre-preamble peer’s body).
Sourcepub fn wire_format_version(expected: u8, got: u8) -> Self
pub fn wire_format_version(expected: u8, got: u8) -> Self
Creates a wire-format mismatch for a wrong wire-format version.
Used when the magic is valid but the wire_format_version byte names a
version this peer does not speak.
Sourcepub fn is_transport(&self) -> bool
pub fn is_transport(&self) -> bool
Returns true if this is a transport error.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true if this is a timeout error.
Sourcepub fn is_connection_lost(&self) -> bool
pub fn is_connection_lost(&self) -> bool
Returns true if this is a connection lost error.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns true if this is a shutdown error.
Sourcepub fn is_wire_format_mismatch(&self) -> bool
pub fn is_wire_format_mismatch(&self) -> bool
Returns true if this is a wire-format mismatch (bad magic OR wrong
wire-format version) — the typed fail-loud signal for cross-version
sync, distinct from a generic SyncError::Serialization.
Trait Implementations§
Source§impl Error for SyncError
impl Error for SyncError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for SyncError
impl RefUnwindSafe for SyncError
impl Send for SyncError
impl Sync for SyncError
impl Unpin for SyncError
impl UnsafeUnpin for SyncError
impl UnwindSafe for SyncError
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more