pub struct PeerConn {
peer: Arc<Peer>,
proto_id: ProtocolID,
}Expand description
Per-protocol view of a Peer with the protocol id baked in. Built
by karyon and handed to the protocol constructor. Hides the
underlying proto_id routing so user code never types it.
Fields§
§peer: Arc<Peer>§proto_id: ProtocolIDImplementations§
Source§impl PeerConn
impl PeerConn
Sourcepub(crate) fn new(peer: Arc<Peer>, proto_id: ProtocolID) -> Self
pub(crate) fn new(peer: Arc<Peer>, proto_id: ProtocolID) -> Self
karyon-internal constructor. User code receives a fully-built
PeerConn from the protocol constructor closure.
Sourcepub async fn send(&self, payload: Vec<u8>) -> Result<()>
pub async fn send(&self, payload: Vec<u8>) -> Result<()>
Send pre-encoded payload bytes to the peer on this protocol.
Sourcepub async fn recv(&self) -> Result<Vec<u8>>
pub async fn recv(&self) -> Result<Vec<u8>>
Receive the next message bytes. Returns Err(PeerShutdown)
when the peer is closing – callers can treat that as an
orderly end of stream.
Auto Trait Implementations§
impl Freeze for PeerConn
impl !RefUnwindSafe for PeerConn
impl Send for PeerConn
impl Sync for PeerConn
impl Unpin for PeerConn
impl UnsafeUnpin for PeerConn
impl !UnwindSafe for PeerConn
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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