Struct fizyr_rpc::Peer[][src]

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

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

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.

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.

Connect to a remote server.

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>.

Run the read/write loop.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.