pub struct Network {
recv: NetworkReceiver,
send: NetworkSender,
}Fields§
§recv: NetworkReceiver§send: NetworkSenderImplementations§
Source§impl Network
impl Network
pub async fn create(conf: Config) -> Result<Self, NetworkError>
pub fn sender(&self) -> &NetworkSender
pub fn receiver(&self) -> &NetworkReceiver
pub fn receiver_mut(&mut self) -> &mut NetworkReceiver
pub fn split_into(self) -> (NetworkSender, NetworkReceiver)
pub async fn receive(&mut self) -> Option<(PublicKey, Bytes)>
Methods from Deref<Target = NetworkSender>§
pub fn config(&self) -> &Config
Sourcepub fn unicast(
&self,
s: Slot,
to: PublicKey,
msg: Vec<u8>,
) -> Result<(), NetworkError>
pub fn unicast( &self, s: Slot, to: PublicKey, msg: Vec<u8>, ) -> Result<(), NetworkError>
Send a message to a party, identified by the given public key.
Sourcepub fn broadcast(&self, s: Slot, msg: Vec<u8>) -> Result<(), NetworkError>
pub fn broadcast(&self, s: Slot, msg: Vec<u8>) -> Result<(), NetworkError>
Send a message to all parties.
Sourcepub fn multicast<P>(
&self,
s: Slot,
to: P,
msg: Vec<u8>,
) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
pub fn multicast<P>(
&self,
s: Slot,
to: P,
msg: Vec<u8>,
) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
Send a message to several parties, identified by their public keys.
Sourcepub fn send(&self, cmd: SendCommand) -> Result<(), NetworkError>
pub fn send(&self, cmd: SendCommand) -> Result<(), NetworkError>
General send operation, supporting custom retry policies.
Sourcepub fn add_peers<P>(&self, r: Role, peers: P) -> Result<(), NetworkError>
pub fn add_peers<P>(&self, r: Role, peers: P) -> Result<(), NetworkError>
Add the given peers to the network.
Sourcepub fn remove_peers<P>(&self, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
pub fn remove_peers<P>(&self, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
Remove the given peers from the network.
Sourcepub fn assign_peers<P>(&self, r: Role, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
pub fn assign_peers<P>(&self, r: Role, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
Assign the given role to the given peers.
Sourcepub fn gc(&self, s: Slot) -> Result<(), NetworkError>
pub fn gc(&self, s: Slot) -> Result<(), NetworkError>
Trigger garbage collection of messages below the given slot.
Sourcepub fn shutdown(&self) -> Result<impl Future<Output = ()> + use<>, NetworkError>
pub fn shutdown(&self) -> Result<impl Future<Output = ()> + use<>, NetworkError>
Trigger network shutdown.
The returned future will resolve once the server task finished.
Sourcefn length_check(&self, msg: &[u8]) -> Result<(), NetworkError>
fn length_check(&self, msg: &[u8]) -> Result<(), NetworkError>
Check the number of message bytes does not exceed the configured maximum.
Sourcefn lt_lower_bound(&self, s: Slot) -> bool
fn lt_lower_bound(&self, s: Slot) -> bool
Check if the given slot is less than our lower bound.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Network
impl !RefUnwindSafe for Network
impl Send for Network
impl Sync for Network
impl Unpin for Network
impl UnsafeUnpin for Network
impl !UnwindSafe for Network
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