Crates.io | tls-api |
lib.rs | tls-api |
version | 0.12.0 |
source | src |
created_at | 2017-06-03 07:20:16.512728 |
updated_at | 2024-11-25 13:32:57.157634 |
description | TLS API without implementation |
homepage | |
repository | https://github.com/edgedb/rust-tls-api/ |
max_upload_size | |
id | 17429 |
size | 66,772 |
Implementation neutral common denominator TLS API.
A library working with TLS can be written with this crate independently on actual TLS implementation, and the user of the library can fill in the actual type implementation.
This crate only provide interfaces: acceptor and connector.
This crate (and dependent tls-api-* crates) have two mutially exclusive features:
runtime-tokio
implements API over tokioruntime-async-std
implements API over async-stdAPI is provided in static or dynamic flavors.
tls_api::TlsAcceptor
and tls_api::TlsConnector
type
are Sized
, each function or structure using them
need to be parameterized by these types, for example:
async fn create_listener<C: tls_api::TlsAcceptor>()
-> anyhow::Result<tls_api::TlsStream<async_std::net::TcpStream>>
{ ... }
Alternatively, there's a dynamically-dispatched version of the functions:
tls_api::TlsAcceptorType
and tls_api::TlsConnectorType
.
These types are not sized. Could be used like this:
async fn create_listener(acceptor: &tls_api::TlsAcceptorType)
-> anyhow::Result<tls_api::TslStreamBox>
{ ... }
Note create_listener
does not have a type parameter,
which makes coding slightly easier at cost of somewhat
decreased performance.