[][src]Struct fizyr_rpc::Server

pub struct Server<Listener> where
    Listener: ServerListener
{ /* fields omitted */ }

Server that spawns peers for all accepted connections.

Implementations

impl<Listener: ServerListener> Server<Listener>[src]

pub fn new(listener: Listener, config: Listener::Config) -> Self[src]

Create a server on a listening socket.

The passed in config is used to create transports and peers for all accepted connections.

pub async fn bind<'a, Address: 'a>(
    address: Address,
    config: Listener::Config
) -> Result<Self> where
    Listener: Bind<'a, Address>, 
[src]

Create a server with a new listening socket bound to the given address.

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

This function is asynchronous because it may perform a DNS lookup for some address types.

pub async fn run<F, R, '_>(&'_ mut self, task: F) -> Result<()> where
    F: FnMut(PeerHandle<Listener::Body>) -> R,
    R: Future<Output = ()> + Send + 'static, 
[src]

Run the server.

The server will accept connections in a loop and spawn a user task for each new peer.

pub async fn accept<'_>(&'_ mut self) -> Result<PeerHandle<Listener::Body>>[src]

Accept a connection and spawn a peer for it.

A Peer is spawned for the new connection, and a PeerHandle is returned to allow interaction with the peer.

Auto Trait Implementations

impl<Listener> RefUnwindSafe for Server<Listener> where
    Listener: RefUnwindSafe,
    <Listener as ServerListener>::Config: RefUnwindSafe

impl<Listener> Send for Server<Listener> where
    Listener: Send,
    <Listener as ServerListener>::Config: Send

impl<Listener> Sync for Server<Listener> where
    Listener: Sync,
    <Listener as ServerListener>::Config: Sync

impl<Listener> Unpin for Server<Listener> where
    <Listener as ServerListener>::Config: Unpin

impl<Listener> UnwindSafe for Server<Listener> where
    Listener: UnwindSafe,
    <Listener as ServerListener>::Config: UnwindSafe

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.