[−][src]Struct fizyr_rpc::Peer
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]
address: Address,
config: Transport::Config
) -> Result<PeerHandle<Transport::Body>> where
Address: 'a,
Transport: Connect<'a, Address>,
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(self)
[src]
Run the read/write loop.
Auto Trait Implementations
impl<Transport> !RefUnwindSafe for Peer<Transport>
[src]
impl<Transport> Send for Peer<Transport>
[src]
impl<Transport> Sync for Peer<Transport> where
Transport: Sync,
[src]
Transport: Sync,
impl<Transport> Unpin for Peer<Transport> where
Transport: Unpin,
[src]
Transport: Unpin,
impl<Transport> !UnwindSafe for Peer<Transport>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,