Struct tokio_uds_proto::UnixServer
[−]
[src]
pub struct UnixServer<Kind, P> { /* fields omitted */ }
A builder for Unix Socket servers.
Setting up a server needs, at minimum:
- A server protocol implementation
- An path
- 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> UnixServer<Kind, P> where P: BindServer<Kind, UnixStream> + Send + Sync + 'static
[src]
fn new(protocol: P, path: PathBuf) -> UnixServer<Kind, P>
Starts building a server for the given protocol and path, with default configuration.
Generally, a protocol is implemented not by implementing the
BindServer
trait directly, but instead by implementing one of the
protocol traits:
tokio_proto::pipeline::ServerProto
tokio_proto::multiplex::ServerProto
tokio_proto::streaming::pipeline::ServerProto
tokio_proto::streaming::multiplex::ServerProto
See the crate documentation for more details on those traits.
fn path(&mut self, path: PathBuf)
Set the path for the server.
fn serve<S>(&self, new_service: S) where S: NewService + Send + Sync + 'static,
S::Instance: 'static,
P::ServiceError: 'static,
P::ServiceResponse: 'static,
P::ServiceRequest: 'static,
S::Request: From<P::ServiceRequest>,
S::Response: Into<P::ServiceResponse>,
S::Error: Into<P::ServiceError>
S::Instance: 'static,
P::ServiceError: 'static,
P::ServiceResponse: 'static,
P::ServiceRequest: 'static,
S::Request: From<P::ServiceRequest>,
S::Response: Into<P::ServiceResponse>,
S::Error: Into<P::ServiceError>
Start up the server, providing the given service on it.
This method will block the current thread until the server is shut down.
fn with_handle<F, S>(&self, new_service: F) where F: Fn(&Handle) -> S + Send + Sync + 'static,
S: NewService + Send + Sync + 'static,
S::Instance: 'static,
P::ServiceError: 'static,
P::ServiceResponse: 'static,
P::ServiceRequest: 'static,
S::Request: From<P::ServiceRequest>,
S::Response: Into<P::ServiceResponse>,
S::Error: Into<P::ServiceError>
S: NewService + Send + Sync + 'static,
S::Instance: 'static,
P::ServiceError: 'static,
P::ServiceResponse: 'static,
P::ServiceRequest: 'static,
S::Request: From<P::ServiceRequest>,
S::Response: Into<P::ServiceResponse>,
S::Error: Into<P::ServiceError>
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.