[][src]Struct silver_rs::Server

pub struct Server<Kind, P> { /* fields omitted */ }

A builder for TCP servers.

Setting up a server needs, at minimum:

  • A server protocol implementation
  • An address
  • A service to provide

In addition to those basics, the builder provides some additional configuration, which is expected to grow over time.

See the crate docs for an example.

Methods

impl<Kind, P> TcpServer<Kind, P> where
    P: BindServer<Kind, TcpStream> + Send + Sync + 'static, 
[src]

pub fn new(protocol: P, addr: SocketAddr) -> TcpServer<Kind, P>[src]

Starts building a server for the given protocol and address, with default configuration.

Generally, a protocol is implemented not by implementing the BindServer trait directly, but instead by implementing one of the protocol traits:

  • pipeline::ServerProto
  • multiplex::ServerProto
  • streaming::pipeline::ServerProto
  • streaming::multiplex::ServerProto

See the crate documentation for more details on those traits.

pub fn addr(&mut self, addr: SocketAddr)[src]

Set the address for the server.

pub fn threads(&mut self, threads: usize)[src]

Set the number of threads running simultaneous event loops (Unix only).

pub fn serve<S>(&self, new_service: S) where
    S: NewService + Send + Sync + 'static,
    <S as NewService>::Instance: 'static,
    <P as BindServer<Kind, TcpStream>>::ServiceError: 'static,
    <P as BindServer<Kind, TcpStream>>::ServiceResponse: 'static,
    <P as BindServer<Kind, TcpStream>>::ServiceRequest: 'static,
    <S as NewService>::Request: From<<P as BindServer<Kind, TcpStream>>::ServiceRequest>,
    <S as NewService>::Response: Into<<P as BindServer<Kind, TcpStream>>::ServiceResponse>,
    <S as NewService>::Error: Into<<P as BindServer<Kind, TcpStream>>::ServiceError>, 
[src]

Start up the server, providing the given service on it.

This method will block the current thread until the server is shut down.

pub fn with_handle<F, S>(&self, new_service: F) where
    F: Fn(&Handle) -> S + Send + Sync + 'static,
    S: NewService + Send + Sync + 'static,
    <S as NewService>::Instance: 'static,
    <P as BindServer<Kind, TcpStream>>::ServiceError: 'static,
    <P as BindServer<Kind, TcpStream>>::ServiceResponse: 'static,
    <P as BindServer<Kind, TcpStream>>::ServiceRequest: 'static,
    <S as NewService>::Request: From<<P as BindServer<Kind, TcpStream>>::ServiceRequest>,
    <S as NewService>::Response: Into<<P as BindServer<Kind, TcpStream>>::ServiceResponse>,
    <S as NewService>::Error: Into<<P as BindServer<Kind, TcpStream>>::ServiceError>, 
[src]

Start up the server, providing the given service on it, and providing access to the event loop handle.

The new_service argument is a closure that is given an event loop handle, and produces a value implementing NewService. That value is in turn used to make a new service instance for each incoming connection.

This method will block the current thread until the server is shut down.

Trait Implementations

impl<Kind, P> Debug for TcpServer<Kind, P> where
    Kind: Debug,
    P: Debug
[src]

Auto Trait Implementations

impl<Kind, P> Send for TcpServer<Kind, P> where
    Kind: Send,
    P: Send + Sync

impl<Kind, P> Sync for TcpServer<Kind, P> where
    Kind: Sync,
    P: Send + Sync

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.

impl<T> Erased for T