//! Auto-generated unsafe bindings to [libcoap](https://github.com/obgm/libcoap), generated using
//! This crate allows direct (but unsafe) usage of the libcoap C library from Rust. The declarations
//! made in this library are generated automatically using bindgen, for further documentation on how
//! another coap library written in pure rust such as [coap-rs](https://github.com/covertness/coap-rs))
//! We currently define a number of features that affect the functionality provided by this wrapper
//! - `dtls`: Enable usage of DTLS for transport security. Supports a number of different backends.
//! re-exporting these features (see [the Cargo Book](https://doc.rust-lang.org/cargo/reference/features.html#dependency-features))
//! the auto-detection order specified in [the libcoap configure script](https://github.com/obgm/libcoap/blob/develop/configure.ac#L494)
//! you. See the relevant parts of the [libcoap license file](https://github.com/obgm/libcoap/blob/develop/LICENSE)
//! - `vendored` (default): Use a vendored version of libcoap instead of the system-provided one.
//! The features that add or remove functionality do not change the generated bindings as libcoap's
//! headers (unlike the source files themselves) are not affected by the corresponding `#define`s.
//! For library users that link to a shared version of libcoap, this means that the feature flags
// Bindgen translates the C headers, clippy's and rustfmt's recommendations are not applicable here.
pub unsafe fn coap_send_rst(session: *mut coap_session_t, request: *const coap_pdu_t) -> coap_mid_t {
/// <https://libcoap.net/doc/reference/develop/group__string.html#ga7f43c10b486dc6d45c37fcaf987d711b>.
/// You *should* prefer using this function over [coap_startup], as without calling this function
/// Either this function or [coap_startup] must be run once before any libcoap function is called.
/// If you are absolutely 100% certain that all features you require are always available (or are
/// prepared to deal with error return values/different behavior on your own if they aren't), you
/// In order to preserve backwards compatibility, this method may (for now) skip the feature checks
/// altogether if they aren't provided by libcoap (which may be the case for libcoap < 4.3.5rc3).
/// If you want to be absolutely certain that a given feature is available, you *must* also check
/// This behavior will be changed as soon as libcoap 4.3.5 is released, after which libcoap 4.3.5
println!("WARNING: coap_startup_with_feature_checks() could not assert the availability of features because the linked version of libcoap is too old (< 4.3.5rc3)!")
// SAFETY: We asserted that context != null, listen_addr is a reference and can therefore not be null.
let uri = unsafe { coap_new_str_const(COAP_TEST_RESOURCE_URI.as_ptr(), COAP_TEST_RESOURCE_URI.len()) };
// SAFETY: We just asserted that uri is valid, COAP_RESOURCE_FLAGS_RELEASE_URI is valid because we will not free the uri ourselves.
let test_resource = unsafe { coap_resource_init(uri, COAP_RESOURCE_FLAGS_RELEASE_URI as c_int) };
// SAFETY: We asserted that test_resource and context are valid, other pointers are always valid.
/// Test case that creates a basic coap server and makes a request to it from a separate context
std::thread::spawn(move || run_coap_test_server(&server_address_clone, preparation_barrier_clone));
unsafe { coap_new_client_session(context, std::ptr::null(), &server_address, COAP_PROTO_UDP) };
// SAFETY: context is asserted to be valid, no known side effects that would violate any guarantees