Skip to main content

Metadata

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> { ... }
}
Available on crate features 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 as_slice(&self) -> &[u8] ⓘ

Return the Metadata as a byte slice.

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>

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".

Implementors§