pub struct Peer {
pub connections: RwLock<RawRwLock, HashMap<ConnectionId, ConnectionState, RandomState>>,
/* private fields */
}
Fields§
§connections: RwLock<RawRwLock, HashMap<ConnectionId, ConnectionState, RandomState>>
Implementations§
source§impl Peer
impl Peer
pub fn new(epoch: u32) -> Arc<Peer, Global>
pub fn epoch(&self) -> u32
pub fn add_connection<F, Fut, Out>( self: &Arc<Peer, Global>, connection: Connection, create_timer: F ) -> (ConnectionId, impl Future<Output = Result<(), Error>> + Send, Pin<Box<dyn Stream<Item = Box<dyn AnyTypedEnvelope, Global>> + Send, Global>>)where F: Send + Fn(Duration) -> Fut, Fut: Send + Future<Output = Out>, Out: Send,
pub fn disconnect(&self, connection_id: ConnectionId)
pub fn reset(&self, epoch: u32)
pub fn teardown(&self)
pub fn request<T>( &self, receiver_id: ConnectionId, request: T ) -> impl Future<Output = Result<<T as RequestMessage>::Response, Error>>where T: RequestMessage,
pub fn request_envelope<T>( &self, receiver_id: ConnectionId, request: T ) -> impl Future<Output = Result<TypedEnvelope<<T as RequestMessage>::Response>, Error>>where T: RequestMessage,
pub fn forward_request<T>( &self, sender_id: ConnectionId, receiver_id: ConnectionId, request: T ) -> impl Future<Output = Result<<T as RequestMessage>::Response, Error>>where T: RequestMessage,
pub fn request_internal<T>( &self, original_sender_id: Option<ConnectionId>, receiver_id: ConnectionId, request: T ) -> impl Future<Output = Result<TypedEnvelope<<T as RequestMessage>::Response>, Error>>where T: RequestMessage,
pub fn send<T>( &self, receiver_id: ConnectionId, message: T ) -> Result<(), Error>where T: EnvelopedMessage,
pub fn forward_send<T>( &self, sender_id: ConnectionId, receiver_id: ConnectionId, message: T ) -> Result<(), Error>where T: EnvelopedMessage,
pub fn respond<T>( &self, receipt: Receipt<T>, response: <T as RequestMessage>::Response ) -> Result<(), Error>where T: RequestMessage,
pub fn respond_with_error<T>( &self, receipt: Receipt<T>, response: Error ) -> Result<(), Error>where T: RequestMessage,
pub fn respond_with_unhandled_message( &self, envelope: Box<dyn AnyTypedEnvelope, Global> ) -> Result<(), Error>
Trait Implementations§
source§impl Serialize for Peer
impl Serialize for Peer
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Peer
impl Send for Peer
impl Sync for Peer
impl Unpin for Peer
impl !UnwindSafe for Peer
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