pub struct Mesh { /* private fields */ }Implementations§
Source§impl Mesh
impl Mesh
pub fn endpoint(&self) -> &Endpoint
pub fn node_key(&self) -> [u8; 32]
Sourcepub fn node_addr(&self) -> EndpointAddr
pub fn node_addr(&self) -> EndpointAddr
Our address as an advertisement carries it: relay only.
pub async fn neighbor_count(&self, topic: &[u8; 32]) -> usize
Sourcepub async fn subscribe(
&self,
topic: [u8; 32],
peers: Vec<EndpointAddr>,
sink: Sender<MeshEvent>,
) -> Result<(), String>
pub async fn subscribe( &self, topic: [u8; 32], peers: Vec<EndpointAddr>, sink: Sender<MeshEvent>, ) -> Result<(), String>
Subscribe to a topic and dial peers. Events go to sink until
unsubscribe. One subscription per topic per process.
Sourcepub async fn add_peer(
&self,
topic: &[u8; 32],
peer: EndpointAddr,
) -> Result<(), String>
pub async fn add_peer( &self, topic: &[u8; 32], peer: EndpointAddr, ) -> Result<(), String>
Bring a newly advertised peer into a live topic, retrying 1 s, then 2 s apart.
pub async fn broadcast( &self, topic: &[u8; 32], payload: Vec<u8>, ) -> Result<(), String>
Sourcepub async fn unsubscribe(&self, topic: &[u8; 32])
pub async fn unsubscribe(&self, topic: &[u8; 32])
Drop every handle on the topic: gossip only forgets a topic once all are gone, and a surviving clone would break the next subscription to it. Returns once they are gone, including those of an unsubscribe already under way; the teardown finishes even if this call is cancelled.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Mesh
impl !RefUnwindSafe for Mesh
impl !UnwindSafe for Mesh
impl Forget for Mesh
impl Move for Mesh
impl Send for Mesh
impl Sync for Mesh
impl Unpin for Mesh
impl UnsafeUnpin for Mesh
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
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> ⓘ
Converts
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> ⓘ
Converts
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