pub struct NetworkHandle {
pub(super) command_sender: UnboundedSender<NetworkCommand>,
}Expand description
A handle for interacting with the NetworkLayer.
This struct provides a thread-safe way to send commands to the NetworkLayer
and receive responses.
Fields§
§command_sender: UnboundedSender<NetworkCommand>Implementations§
Source§impl NetworkHandle
impl NetworkHandle
Sourcepub async fn send_chat_request(
&self,
peer_id: PeerId,
request: ChatRequest,
) -> Result<()>
pub async fn send_chat_request( &self, peer_id: PeerId, request: ChatRequest, ) -> Result<()>
Sourcepub async fn get_connected_peers(&self) -> Result<Vec<PeerId>>
pub async fn get_connected_peers(&self) -> Result<Vec<PeerId>>
Gets the list of connected peers.
§Errors
This function will return an error if the list of peers cannot be retrieved.
Sourcepub async fn mailbox_put(
&self,
peer_id: PeerId,
recipient: [u8; 32],
message: EncryptedMessage,
) -> Result<bool>
pub async fn mailbox_put( &self, peer_id: PeerId, recipient: [u8; 32], message: EncryptedMessage, ) -> Result<bool>
Sourcepub async fn mailbox_fetch(
&self,
peer_id: PeerId,
recipient: [u8; 32],
limit: usize,
) -> Result<Vec<EncryptedMessage>>
pub async fn mailbox_fetch( &self, peer_id: PeerId, recipient: [u8; 32], limit: usize, ) -> Result<Vec<EncryptedMessage>>
Sourcepub async fn mailbox_ack(
&self,
peer_id: PeerId,
recipient: [u8; 32],
msg_ids: Vec<Uuid>,
) -> Result<usize>
pub async fn mailbox_ack( &self, peer_id: PeerId, recipient: [u8; 32], msg_ids: Vec<Uuid>, ) -> Result<usize>
Acknowledges the receipt of messages from a mailbox.
This will delete the acknowledged messages from the mailbox.
§Arguments
peer_id- ThePeerIdof the mailbox node.recipient- The hash of the recipient’s public key.msg_ids- The IDs of the messages to acknowledge.
§Errors
This function will return an error if the messages cannot be acknowledged.
Trait Implementations§
Source§impl Clone for NetworkHandle
impl Clone for NetworkHandle
Source§fn clone(&self) -> NetworkHandle
fn clone(&self) -> NetworkHandle
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkHandle
impl RefUnwindSafe for NetworkHandle
impl Send for NetworkHandle
impl Sync for NetworkHandle
impl Unpin for NetworkHandle
impl UnwindSafe for NetworkHandle
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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