atc_router::ffi::router

Function router_get_fields

Source
#[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 the Router object returned by router_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. if fields is NULL, 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 by router_new.
  • If fields is not NULL, fields must be valid to read and write for fields_len * size_of::<*const u8>() bytes, and it must be properly aligned.
  • If fields is not NULL, fields_len must be valid to read and write for size_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 the Lifetimes section.