Struct libcoap_rs::CoapContext

source ·
pub struct CoapContext<'a> { /* private fields */ }
Expand description

A CoAP Context — container for general state and configuration information relating to CoAP

The equivalent to the coap_context_t type in libcoap.

Implementations

Creates a new context.

Errors

Returns an error if the underlying libcoap library was unable to create a new context (probably an allocation error?).

Performs a controlled shutdown of the CoAP context.

This will perform all still outstanding IO operations until coap_can_exit() confirms that the context has no more outstanding IO and can be dropped without interrupting sessions.

Creates a new UDP endpoint that is bound to the given address.

TODO

Creates a new DTLS endpoint that is bound to the given address.

Note that in order to actually connect to DTLS clients, you need to set a crypto provider using set_server_crypto_provider()

TODO

Adds the given resource to the resource pool of this context.

Sets the server-side cryptography information provider.

Performs currently outstanding IO operations, waiting for a maximum duration of timeout.

This is the function where most of the IO operations made using this library are actually executed. It is recommended to call this function in a loop for as long as the CoAP context is used.

Return the duration that idle server-side sessions are kept alive if they are not referenced or used anywhere else.

Set the duration that idle server-side sessions are kept alive if they are not referenced or used anywhere else.

Panics

Panics if the provided duration is too large to be provided to libcoap (larger than a libc::c_uint).

Returns the maximum number of server-side sessions that can concurrently be in a handshake state.

If this number is exceeded, no new handshakes will be accepted.

Sets the maximum number of server-side sessions that can concurrently be in a handshake state.

If this number is exceeded, no new handshakes will be accepted.

Returns the maximum number of idle server-side sessions for this context.

If this number is exceeded, the oldest unreferenced session will be freed.

Sets the maximum number of idle server-side sessions for this context.

If this number is exceeded, the oldest unreferenced session will be freed.

Returns the maximum size for Capabilities and Settings Messages

CSMs are used in CoAP over TCP as specified in RFC 8323, Section 5.3.

Sets the maximum size for Capabilities and Settings Messages

CSMs are used in CoAP over TCP as specified in RFC 8323, Section 5.3.

Returns the timeout for Capabilities and Settings Messages

CSMs are used in CoAP over TCP as specified in RFC 8323, Section 5.3.

Sets the timeout for Capabilities and Settings Messages

CSMs are used in CoAP over TCP as specified in RFC 8323, Section 5.3.

Panics

Panics if the provided timeout is too large for libcoap (> u32::MAX).

Sets the number of seconds to wait before sending a CoAP keepalive message for idle sessions.

If the provided value is None, CoAP-level keepalive messages will be disabled.

Panics

Panics if the provided duration is too large to be provided to libcoap (larger than a libc::c_uint).

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.