pub struct ReplicationMessage {
pub request_id: u64,
pub body: ReplicationMessageBody,
}Expand description
Top-level replication message envelope.
Every replication wire message carries a sender-assigned request_id so
that the receiver can correlate responses without relying on transport-layer
ordering.
Fields§
§request_id: u64Sender-assigned request ID for correlation.
body: ReplicationMessageBodyThe message body.
Implementations§
Source§impl ReplicationMessage
impl ReplicationMessage
Sourcepub fn encode(&self) -> Result<Vec<u8>, ReplicationProtocolError>
pub fn encode(&self) -> Result<Vec<u8>, ReplicationProtocolError>
Encode the message to bytes using postcard.
§Errors
Returns ReplicationProtocolError::SerializationFailed if postcard
serialization fails.
Sourcepub fn decode(data: &[u8]) -> Result<Self, ReplicationProtocolError>
pub fn decode(data: &[u8]) -> Result<Self, ReplicationProtocolError>
Decode a message from bytes using postcard.
Rejects payloads larger than MAX_REPLICATION_MESSAGE_SIZE before
attempting deserialization.
§Errors
Returns ReplicationProtocolError::MessageTooLarge if the input
exceeds the size limit, or
ReplicationProtocolError::DeserializationFailed if postcard cannot
parse the data.
Sourcepub fn decode_subtree_audit_response(
data: &[u8],
) -> Result<Self, ReplicationProtocolError>
pub fn decode_subtree_audit_response( data: &[u8], ) -> Result<Self, ReplicationProtocolError>
Decode a reply to a subtree-audit challenge under the subtree-family ceiling.
The pre-decode ceiling on the receive path bounds what an auditor can
make a responder decode. This is that same bound in the other direction.
A subtree challenge costs a few hundred bytes to send, so without it a challenged
peer could answer with up to MAX_REPLICATION_MESSAGE_SIZE and make
the auditor allocate and decode all of it — the cheap side of the
exchange paying for the expensive one, which is the shape the responder
ceiling exists to prevent. Subtree-audit bodies are ~110 KiB at worst (see
MAX_SUBTREE_AUDIT_MESSAGE_SIZE), so this costs an honest responder nothing.
No discriminant peek is needed here, unlike the receive path: the auditor asked the question, so it already knows the reply belongs to the subtree family, and a body that turns out not to be the expected one is rejected by the subtree lane’s own matching afterwards.
§Errors
Returns ReplicationProtocolError::MessageTooLarge above the subtree
audit ceiling.
Trait Implementations§
Source§impl Clone for ReplicationMessage
impl Clone for ReplicationMessage
Source§impl Debug for ReplicationMessage
impl Debug for ReplicationMessage
Source§impl<'de> Deserialize<'de> for ReplicationMessage
impl<'de> Deserialize<'de> for ReplicationMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ReplicationMessage
impl RefUnwindSafe for ReplicationMessage
impl Send for ReplicationMessage
impl Sync for ReplicationMessage
impl Unpin for ReplicationMessage
impl UnsafeUnpin for ReplicationMessage
impl UnwindSafe for ReplicationMessage
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
impl<'de, T> BorrowedRpcObject<'de> for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more