pub struct MeshService { /* private fields */ }Expand description
A handle to a running mesh: sole owner of the inbound packet stream and the thread’s join handle,
plus a MeshControl. Clone control for additional control handles; the
inbound receiver stays single-owner (only the mesh’s consumer — e.g. the chat loop — drains it).
Implementations§
Source§impl MeshService
impl MeshService
Sourcepub fn spawn(mesh: SocialWebNet) -> MeshService
pub fn spawn(mesh: SocialWebNet) -> MeshService
Spawn the mesh thread, taking ownership of an already-constructed SocialWebNet (peers may
be pre-added or added later via add_peer).
Sourcepub fn control(&self) -> MeshControl
pub fn control(&self) -> MeshControl
A cloneable control handle to this mesh — share it with a status UI, a chat loop, etc. All
control handles and the MeshService itself drive the same mesh thread.
Sourcepub fn add_peer(
&self,
peer_id: &str,
peer_pubkey_hex: &str,
endpoint: Option<SocketAddr>,
) -> Result<SocketAddr, String>
pub fn add_peer( &self, peer_id: &str, peer_pubkey_hex: &str, endpoint: Option<SocketAddr>, ) -> Result<SocketAddr, String>
Add a peer; returns the local socket address the tunnel bound (advertise it to the peer).
Sourcepub fn set_peer_endpoint(
&self,
peer_id: &str,
addr: SocketAddr,
) -> Result<(), String>
pub fn set_peer_endpoint( &self, peer_id: &str, addr: SocketAddr, ) -> Result<(), String>
Point a peer’s tunnel at addr.
Sourcepub fn initiate_handshake(&self, peer_id: &str) -> Result<(), String>
pub fn initiate_handshake(&self, peer_id: &str) -> Result<(), String>
Start the handshake with a peer (initiator side; endpoint must be set).
Sourcepub fn send(&self, peer_id: &str, inner: Vec<u8>) -> Result<bool, String>
pub fn send(&self, peer_id: &str, inner: Vec<u8>) -> Result<bool, String>
Encrypt and send one inner IPv6 packet to a peer.
Sourcepub fn remove_peer(&self, peer_id: &str) -> Result<bool, String>
pub fn remove_peer(&self, peer_id: &str) -> Result<bool, String>
Remove a peer; returns whether it was present.
Sourcepub fn has_session(&self, peer_id: &str) -> Result<bool, String>
pub fn has_session(&self, peer_id: &str) -> Result<bool, String>
Whether a live session exists with a peer.
Sourcepub fn try_recv(&self) -> Option<MeshPacket>
pub fn try_recv(&self) -> Option<MeshPacket>
Non-blocking receive of the next inbound inner packet, if any.
Sourcepub fn recv_timeout(&self, timeout: Duration) -> Option<MeshPacket>
pub fn recv_timeout(&self, timeout: Duration) -> Option<MeshPacket>
Block up to timeout for the next inbound inner packet.
Sourcepub fn wait_for_session(&self, peer_id: &str, timeout: Duration) -> bool
pub fn wait_for_session(&self, peer_id: &str, timeout: Duration) -> bool
Poll until a session is established with peer_id, or timeout elapses. Returns whether the
session came up.
Trait Implementations§
Source§impl Drop for MeshService
impl Drop for MeshService
Auto Trait Implementations§
impl Freeze for MeshService
impl !RefUnwindSafe for MeshService
impl Send for MeshService
impl !Sync for MeshService
impl Unpin for MeshService
impl UnsafeUnpin for MeshService
impl !UnwindSafe for MeshService
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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