[][src]Struct fizyr_rpc::Peer

pub struct Peer<Transport: Transport> { /* fields omitted */ }

Peer read/write loop.

This struct is used to run the read/write loop of the peer. To send or receive requests and stream messages, you need to use the PeerHandle instead.

Implementations

impl<Transport: Transport> Peer<Transport>[src]

pub fn new(transport: Transport) -> (Self, PeerHandle<Transport::Body>)[src]

Create a new peer and a handle to it.

The Peer itself is used to run the read/write loop. The returned PeerHandle is used to send and receive requests and stream messages.

If Self::run() is not called (or aborted), then none of the functions of the PeerHandle will work. They will just wait forever.

You can also use Self::spawn() to run the read/write loop in a newly spawned task, and only get a PeerHandle. You should only use Self::spawn() if you do not need full control over the execution of the read/write loop.

pub fn spawn(transport: Transport) -> PeerHandle<Transport::Body>[src]

Spawn a peer in a new task, and get a handle to the peer.

The spawned task will immediately be detached. It can not be joined.

The returned PeerHandle can be used to send and receive requests and stream messages.

If you need more control of the execution of the peer read/write loop, you should use Self::new() instead.

pub async fn connect<'a, Address>(
    address: Address,
    config: Transport::Config
) -> Result<PeerHandle<Transport::Body>> where
    Address: 'a,
    Transport: Connect<'a, Address>, 
[src]

Connect to a remote peer.

Similar to Self::spawn(), this spawns a background task for the peer.

The returned PeerHandle can be used to send and receive requests and stream messages.

The type of address accepted depends on the transport. For internet transports such as TCP, the address must implement tokio::net::ToSocketAddrs. For unix transports, the address must implement AsRef<std::path::Path>.

pub async fn run(__arg0: Self)[src]

Run the read/write loop.

Auto Trait Implementations

impl<Transport> !RefUnwindSafe for Peer<Transport>

impl<Transport> Send for Peer<Transport> where
    <Transport as Transport>::Body: Send

impl<Transport> Sync for Peer<Transport> where
    Transport: Sync,
    <Transport as Transport>::Body: Send

impl<Transport> Unpin for Peer<Transport> where
    Transport: Unpin

impl<Transport> !UnwindSafe for Peer<Transport>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.