Trait Metadata
pub trait Metadata:
Debug
+ Send
+ Sync {
// Required methods
fn as_slice(&self) -> &[u8] ⓘ;
fn update(&mut self, data: &[u8]) -> Result<bool, PartialError>;
// Provided method
fn update_from_data(&mut self, _data: &[u8]) -> Result<(), PartialError> { ... }
}gossipsub and partial-messages only.Expand description
Application-defined state describing available and requested parts
of a Partial message.
Metadata is exchanged between peers to advertise which parts of a
logical message are present and which are still needed. It must provide
a byte representation for wire transmission and support in-place updates
when remote metadata is received.
update merges remote metadata into the local view and reports whether
the state changed. update_from_data optionally tracks what the remote
peer believes our state to be (default is a no-op).
Required Methods§
fn update(&mut self, data: &[u8]) -> Result<bool, PartialError>
fn update(&mut self, data: &[u8]) -> Result<bool, PartialError>
Attempts to update the Metadata with the remote metadata,
Returns true if the Metadata was updated.
Provided Methods§
fn update_from_data(&mut self, _data: &[u8]) -> Result<(), PartialError>
fn update_from_data(&mut self, _data: &[u8]) -> Result<(), PartialError>
Attempts to update the local Metadata with the remote data received.
This method is used to track the metadata that the remote peer believes the local system
has. The default returns Ok(()) as it is an optimization, indicating that the update
logic has not been triggered in this implementation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".