[−][src]Trait libp2p_gossipsub::DataTransform
A general trait of transforming a RawGossipsubMessage
into a GossipsubMessage
. The
RawGossipsubMessage
is obtained from the wire and the GossipsubMessage
is used to
calculate the crate::MessageId
of the message and is what is sent to the application.
The inbound/outbound transforms must be inverses. Applying the inbound transform and then the outbound transform MUST leave the underlying data un-modified.
By default, this is the identity transform for all fields in GossipsubMessage
.
Required methods
pub fn inbound_transform(
&self,
raw_message: RawGossipsubMessage
) -> Result<GossipsubMessage, Error>
[src]
&self,
raw_message: RawGossipsubMessage
) -> Result<GossipsubMessage, Error>
Takes a RawGossipsubMessage
received and converts it to a GossipsubMessage
.
pub fn outbound_transform(
&self,
topic: &TopicHash,
data: Vec<u8>
) -> Result<Vec<u8>, Error>
[src]
&self,
topic: &TopicHash,
data: Vec<u8>
) -> Result<Vec<u8>, Error>
Takes the data to be published (a topic and associated data) transforms the data. The
transformed data will then be used to create a crate::RawGossipsubMessage
to be sent to peers.
Implementors
impl DataTransform for IdentityTransform
[src]
pub fn inbound_transform(
&self,
raw_message: RawGossipsubMessage
) -> Result<GossipsubMessage, Error>
[src]
&self,
raw_message: RawGossipsubMessage
) -> Result<GossipsubMessage, Error>
pub fn outbound_transform(
&self,
_topic: &TopicHash,
data: Vec<u8>
) -> Result<Vec<u8>, Error>
[src]
&self,
_topic: &TopicHash,
data: Vec<u8>
) -> Result<Vec<u8>, Error>