Struct reactive_messaging::prelude::Peer
source · pub struct Peer<const CONFIG: u64, LocalMessages: ReactiveMessagingSerializer<LocalMessages> + Send + Sync + PartialEq + Debug + 'static, SenderChannel: FullDuplexUniChannel<ItemType = LocalMessages, DerivedItemType = LocalMessages> + Send + Sync> {
pub peer_id: u32,
pub peer_address: SocketAddr,
/* private fields */
}Expand description
Represents a reactive channel connected to a remote peer, through which we’re able to send out “local messages” of type RetryableSenderImpl::LocalMessages.
the Self::send() method honors whatever retrying config is specified in [RetryableSenderImpl::CONST_CONFIG].
IMPLEMENTATION NOTE: GAT traits (to reduce the number of generic parameters) couldn’t be used here – even after applying this compiler bug workaround https://github.com/rust-lang/rust/issues/102211#issuecomment-1513931928
– the “error: implementation of std::marker::Send is not general enough” bug kept on popping up in user provided closures that called other async functions.
Fields§
§peer_id: u32§peer_address: SocketAddrImplementations§
source§impl<const CONFIG: u64, LocalMessages: ReactiveMessagingSerializer<LocalMessages> + Send + Sync + PartialEq + Debug, SenderChannel: FullDuplexUniChannel<ItemType = LocalMessages, DerivedItemType = LocalMessages> + Send + Sync> Peer<CONFIG, LocalMessages, SenderChannel>
impl<const CONFIG: u64, LocalMessages: ReactiveMessagingSerializer<LocalMessages> + Send + Sync + PartialEq + Debug, SenderChannel: FullDuplexUniChannel<ItemType = LocalMessages, DerivedItemType = LocalMessages> + Send + Sync> Peer<CONFIG, LocalMessages, SenderChannel>
pub fn new( retryable_sender: ReactiveMessagingSender<CONFIG, LocalMessages, SenderChannel>, peer_address: SocketAddr ) -> Self
sourcepub fn create_stream(
&self
) -> (MutinyStream<'static, LocalMessages, SenderChannel, LocalMessages>, u32)
pub fn create_stream( &self ) -> (MutinyStream<'static, LocalMessages, SenderChannel, LocalMessages>, u32)
Asks the underlying channel to revert to Stream-mode (rather than Execution-mode), returning the Stream
pub fn send(&self, message: LocalMessages) -> Result<(), (bool, String)>
pub async fn send_async( &self, message: LocalMessages ) -> Result<(), (bool, String)>
pub fn pending_items_count(&self) -> u32
pub fn buffer_size(&self) -> u32
pub async fn flush_and_close(&self, timeout: Duration) -> u32
pub fn cancel_and_close(&self)
Trait Implementations§
Auto Trait Implementations§
impl<const CONFIG: u64, LocalMessages, SenderChannel> RefUnwindSafe for Peer<CONFIG, LocalMessages, SenderChannel>where SenderChannel: RefUnwindSafe,
impl<const CONFIG: u64, LocalMessages, SenderChannel> Send for Peer<CONFIG, LocalMessages, SenderChannel>
impl<const CONFIG: u64, LocalMessages, SenderChannel> Sync for Peer<CONFIG, LocalMessages, SenderChannel>
impl<const CONFIG: u64, LocalMessages, SenderChannel> Unpin for Peer<CONFIG, LocalMessages, SenderChannel>
impl<const CONFIG: u64, LocalMessages, SenderChannel> UnwindSafe for Peer<CONFIG, LocalMessages, SenderChannel>where SenderChannel: RefUnwindSafe,
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