pub struct AsyncServer<ServiceT: AsyncService> { /* private fields */ }
Expand description
An async server that handles client connections and manages the application service implementing the AsyncService
trait.
The server listens for incoming connections and spawns a new tasks for each client connection.\
§Example: Self-Signed
ⓘ
let (key, private_key) = cert::self_signed(&["localhost"])?;
let config = ServerConfig::builder()
.with_no_client_auth()
.with_single_cert(vec![key.cert.der().clone()], private_key)?;
let server = AsyncServer::new(config);
server.serve()?
Implementations§
Source§impl<ServiceT> AsyncServer<ServiceT>
impl<ServiceT> AsyncServer<ServiceT>
Sourcepub fn new(service: ServiceT, config: ServerConfig) -> Self
pub fn new(service: ServiceT, config: ServerConfig) -> Self
Creates a new AsyncServer
instance with the provided server configuration.
The ServerConfig
is used to configure the TLS settings for the server.
Sourcepub async fn serve(self) -> Result<()>
pub async fn serve(self) -> Result<()>
Starts the server and listens for incoming connections on the default port (1122).
This method blocks until the server is stopped or an error occurs.
Sourcepub async fn serve_port(self, port: u16) -> Result<()>
pub async fn serve_port(self, port: u16) -> Result<()>
Starts the server and listens for incoming connections on the specified port.
This method blocks until the server is stopped or an error occurs.
Trait Implementations§
Source§impl<ServiceT: Clone + AsyncService> Clone for AsyncServer<ServiceT>
impl<ServiceT: Clone + AsyncService> Clone for AsyncServer<ServiceT>
Source§fn clone(&self) -> AsyncServer<ServiceT>
fn clone(&self) -> AsyncServer<ServiceT>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<ServiceT> Freeze for AsyncServer<ServiceT>where
ServiceT: Freeze,
impl<ServiceT> !RefUnwindSafe for AsyncServer<ServiceT>
impl<ServiceT> Send for AsyncServer<ServiceT>
impl<ServiceT> Sync for AsyncServer<ServiceT>
impl<ServiceT> Unpin for AsyncServer<ServiceT>where
ServiceT: Unpin,
impl<ServiceT> !UnwindSafe for AsyncServer<ServiceT>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more