Skip to main content

ServerBuilder

Struct ServerBuilder 

Source
pub struct ServerBuilder<A: TlsAcceptor = TlsAcceptor> {
    pub conf: ServerConf,
    pub tls: ServerTlsOption<A>,
    pub addr: Option<AnySocketAddr>,
    pub event_loop: Option<Handle>,
    pub conn_event_loops: Vec<Handle>,
    pub service: ServerHandlerPaths,
}

Fields§

§conf: ServerConf§tls: ServerTlsOption<A>§addr: Option<AnySocketAddr>§event_loop: Option<Handle>

Event loop to spawn server. If not specified, builder will create new event loop in a new thread.

§conn_event_loops: Vec<Handle>

Event loops used to run incoming connections. If empty, listener event loop will be used.

§service: ServerHandlerPaths

Implementations§

Source§

impl ServerBuilder<TlsAcceptor>

Source

pub fn new_plain() -> ServerBuilder<TlsAcceptor>

New server builder with defaults.

Port must be set, other properties are optional.

Source§

impl ServerBuilder<TlsAcceptor>

Source

pub fn new_plain_unix() -> ServerBuilder<TlsAcceptor>

New unix domain socket server with defaults

Addr must be set, other properties are optional.

Source§

impl<A: TlsAcceptor> ServerBuilder<A>

Source

pub fn set_port(&mut self, port: u16)

Set port server listens on. Can be zero to bind on any available port, which can be later obtained by Server::local_addr.

Source

pub fn set_addr<S: ToSocketAddrs>(&mut self, addr: S) -> Result<()>

Set port server listens on.

Source§

impl<A: TlsAcceptor> ServerBuilder<A>

Source

pub fn set_unix_addr<S: Into<SocketAddrUnix>>(&mut self, addr: S) -> Result<()>

Source§

impl<A: TlsAcceptor> ServerBuilder<A>

Source

pub fn new() -> ServerBuilder<A>

New server builder with defaults.

To call this function ServerBuilder must be parameterized with TLS acceptor. If TLS is not needed, ServerBuilder::new_plain function can be used.

Port must be set, other properties are optional.

Source

pub fn set_tls(&mut self, acceptor: A)

Source

pub fn build(self) -> Result<Server>

Auto Trait Implementations§

§

impl<A> Freeze for ServerBuilder<A>

§

impl<A = TlsAcceptor> !RefUnwindSafe for ServerBuilder<A>

§

impl<A> Send for ServerBuilder<A>

§

impl<A> Sync for ServerBuilder<A>

§

impl<A> Unpin for ServerBuilder<A>

§

impl<A> UnsafeUnpin for ServerBuilder<A>

§

impl<A = TlsAcceptor> !UnwindSafe for ServerBuilder<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.