#[no_mangle]
pub unsafe extern "C" fn router_get_fields(
router: &Router<'_>,
fields: *mut *const u8,
fields_len: *mut usize,
) -> usize
Expand description
Get the de-duplicated fields that are actually used in the router. This is useful when you want to know what fields are actually used in the router, so you can generate their values on-demand.
§Arguments
router
: a pointer to theRouter
object returned byrouter_new
.fields
: a pointer to an array of pointers to the field names (NOT C-style strings) that are actually used in the router, which will be filled in. iffields
isNULL
, this function will only return the number of fields used in the router.fields_len
: a pointer to an array of the length of each field name.
§Lifetimes
The string pointers stored in fields
might be invalidated if any of the following
operations are happened:
- The
router
was deallocated. - A new matcher was added to the
router
. - A matcher was removed from the
router
.
§Returns
Returns the number of fields that are actually used in the router.
§Errors
This function never fails.
§Safety
Violating any of the following constraints will result in undefined behavior:
router
must be a valid pointer returned byrouter_new
.- If
fields
is notNULL
,fields
must be valid to read and write forfields_len * size_of::<*const u8>()
bytes, and it must be properly aligned. - If
fields
is notNULL
,fields_len
must be valid to read and write forsize_of::<usize>()
bytes, and it must be properly aligned. - DO NOT write the memory pointed by the elements of
fields
. - DO NOT access the memory pointed by the elements of
fields
after it becomes invalid, see theLifetimes
section.