pub struct HttpOrHttpsAcceptor { /* private fields */ }Expand description
Accept either an HTTP or HTTPS connection using Hyper
Implementations§
Source§impl HttpOrHttpsAcceptor
impl HttpOrHttpsAcceptor
Sourcepub const fn new(listener: TcpListener) -> Self
pub const fn new(listener: TcpListener) -> Self
Creates a new HttpOrHttpsAcceptor configured to only serve HTTP
Sourcepub fn with_tls(self, tls: TlsAcceptor) -> Self
pub fn with_tls(self, tls: TlsAcceptor) -> Self
Configures this HttpOrHttpsAcceptor to serve HTTPS using the provided TlsAcceptor
If you need to create a TlsAcceptor, see the helper functions in rustls_helpers
Sourcepub async fn accept<S>(
&self,
service: S,
) -> Result<(SocketAddr, impl Future<Output = Result<(), AcceptorError>> + use<S>), AcceptorError>
pub async fn accept<S>( &self, service: S, ) -> Result<(SocketAddr, impl Future<Output = Result<(), AcceptorError>> + use<S>), AcceptorError>
Accepts a singular connection. Returns a the peer address of the connected client and a future that MUST be spawned to serve the connection.
§Errors
The function will return an error if the TCP connection fails, the returned future will return an error if the TLS handshake or Hyper service fails.
Auto Trait Implementations§
impl !Freeze for HttpOrHttpsAcceptor
impl !RefUnwindSafe for HttpOrHttpsAcceptor
impl Send for HttpOrHttpsAcceptor
impl Sync for HttpOrHttpsAcceptor
impl Unpin for HttpOrHttpsAcceptor
impl !UnwindSafe for HttpOrHttpsAcceptor
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