Struct libp2p_pubsub_core::SubscriptionBuilder
source · pub struct SubscriptionBuilder { /* private fields */ }
Expand description
A builder for a subscription.
Implementations§
source§impl SubscriptionBuilder
impl SubscriptionBuilder
sourcepub fn message_id_fn<F>(&mut self, id_fn: F) -> &mut Selfwhere
F: Fn(&FrameMessage) -> MessageId + Send + Sync + 'static,
pub fn message_id_fn<F>(&mut self, id_fn: F) -> &mut Selfwhere F: Fn(&FrameMessage) -> MessageId + Send + Sync + 'static,
A user-defined function allowing the user to specify the message id of a pub-sub message.
The default value is to concatenate the source peer id with a sequence number. Setting this
parameter allows the user to address packets arbitrarily. One example is content based
addressing, where this function may be set to hash(message)
. This would prevent messages
of the same content from being duplicated.
The function takes a FrameMessage
as input and outputs a String to be interpreted as the
message id.
pub fn build(self) -> Subscription
Auto Trait Implementations§
impl !RefUnwindSafe for SubscriptionBuilder
impl !Send for SubscriptionBuilder
impl !Sync for SubscriptionBuilder
impl Unpin for SubscriptionBuilder
impl !UnwindSafe for SubscriptionBuilder
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
Mutably borrows from an owned value. Read more