pub struct CoapDtlsServer { /* private fields */ }Expand description
CoAP/DTLS server for EST-coaps (RFC 9148).
Binds a UDP socket, accepts DTLS connections, parses CoAP messages, routes EST operations, and handles block-wise transfer for large payloads.
§Architecture
UDP socket
└─ DTLS decrypt (per-peer via DtlsContext + DtlsSessionCache)
└─ CoAP parse (CoapMessage::parse)
└─ EST routing (CoapEstRouter::route_message)
└─ Block assembly (BlockAssembler for multi-block requests)
└─ EST handler callback
└─ Block disassembly (BlockDisassembler for large responses)
└─ CoAP encode (CoapMessage::encode)
└─ DTLS encrypt
└─ UDP sendImplementations§
Source§impl CoapDtlsServer
impl CoapDtlsServer
Sourcepub async fn bind(
listen_addr: &str,
cert_pem: &[u8],
key_pem: &[u8],
ca_pem: &[u8],
block_size: u16,
max_payload: usize,
max_sessions: usize,
session_timeout: Duration,
) -> Result<Self, CoapError>
pub async fn bind( listen_addr: &str, cert_pem: &[u8], key_pem: &[u8], ca_pem: &[u8], block_size: u16, max_payload: usize, max_sessions: usize, session_timeout: Duration, ) -> Result<Self, CoapError>
Creates and binds a new CoAP/DTLS server.
§Arguments
listen_addr- UDP address to bind (e.g.,"0.0.0.0:5684").cert_pem- PEM-encoded server certificate for DTLS.key_pem- PEM-encoded server private key for DTLS.ca_pem- PEM-encoded CA certificate for client cert verification.block_size- CoAP block size in bytes (must be a power of 2, 16..=1024).max_payload- Maximum reassembled payload size in bytes.max_sessions- Maximum concurrent DTLS sessions.session_timeout- DTLS session TTL for resumption.
Sourcepub fn local_addr(&self) -> Result<SocketAddr, CoapError>
pub fn local_addr(&self) -> Result<SocketAddr, CoapError>
Returns the local address the server is bound to.
Sourcepub async fn run<H: EstHandler>(&self, handler: Arc<H>) -> Result<(), CoapError>
pub async fn run<H: EstHandler>(&self, handler: Arc<H>) -> Result<(), CoapError>
Runs the CoAP/DTLS server main loop.
Receives UDP datagrams, performs DTLS processing, parses CoAP messages, routes to the EST handler, and sends responses. This method runs indefinitely until the provided cancellation token is signalled or an unrecoverable error occurs.
§Arguments
handler- EST operation handler that processes enrollment requests.
Auto Trait Implementations§
impl !Freeze for CoapDtlsServer
impl !RefUnwindSafe for CoapDtlsServer
impl Send for CoapDtlsServer
impl Sync for CoapDtlsServer
impl Unpin for CoapDtlsServer
impl UnsafeUnpin for CoapDtlsServer
impl !UnwindSafe for CoapDtlsServer
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