pub struct Network {
recv: NetworkReceiver,
ctrl: NetworkController,
}Fields§
§recv: NetworkReceiver§ctrl: NetworkControllerImplementations§
Source§impl Network
impl Network
pub async fn create(conf: Config) -> Result<Self, NetworkError>
pub fn controller(&mut self) -> &mut NetworkController
pub fn receiver(&mut self) -> &mut NetworkReceiver
pub fn split(&self) -> (&NetworkController, &NetworkReceiver)
pub fn split_mut(&mut self) -> (&mut NetworkController, &mut NetworkReceiver)
pub fn split_into(self) -> (NetworkController, NetworkReceiver)
pub async fn receive(&mut self) -> Option<(PublicKey, Bytes)>
Methods from Deref<Target = NetworkController>§
pub fn config(&self) -> &Config
Sourcepub fn unicast(
&mut self,
s: Slot,
to: PublicKey,
msg: Vec<u8>,
) -> Result<(), NetworkError>
pub fn unicast( &mut 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(&mut self, s: Slot, msg: Vec<u8>) -> Result<(), NetworkError>
pub fn broadcast(&mut self, s: Slot, msg: Vec<u8>) -> Result<(), NetworkError>
Send a message to all parties.
Sourcepub fn multicast<P>(
&mut self,
s: Slot,
to: P,
msg: Vec<u8>,
) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
pub fn multicast<P>(
&mut 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(&mut self, cmd: SendCommand) -> Result<(), NetworkError>
pub fn send(&mut self, cmd: SendCommand) -> Result<(), NetworkError>
General send operation, supporting custom retry policies.
Sourcepub fn add_peers<P>(&mut self, r: Role, peers: P) -> Result<(), NetworkError>
pub fn add_peers<P>(&mut self, r: Role, peers: P) -> Result<(), NetworkError>
Add the given peers to the network.
Sourcepub fn remove_peers<P>(&mut self, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
pub fn remove_peers<P>(&mut self, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
Remove the given peers from the network.
Sourcepub fn assign_peers<P>(&mut self, r: Role, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
pub fn assign_peers<P>(&mut self, r: Role, peers: P) -> Result<(), NetworkError>where
P: IntoIterator<Item = PublicKey>,
Assign the given role to the given peers.
pub fn gc(&mut self, s: Slot) -> Result<(), NetworkError>
Sourcepub fn shutdown(
&mut self,
) -> Result<impl Future<Output = ()> + use<>, NetworkError>
pub fn shutdown( &mut 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