#[no_mangle]
pub unsafe extern "C" fn context_get_result(
context: &Context<'_>,
uuid_hex: *mut u8,
matched_field: *const i8,
matched_value: *mut *const u8,
matched_value_len: *mut usize,
capture_names: *mut *const u8,
capture_names_len: *mut usize,
capture_values: *mut *const u8,
capture_values_len: *mut usize,
) -> isize
Expand description
Get the result of the context.
§Arguments
context
: a pointer to theContext
object.uuid_hex
: If notNULL
, the UUID of the matched matcher will be stored.matched_field
: If notNULL
, the field name (C-style string) of the matched value will be stored.matched_value
: If thematched_field
is notNULL
, the value of the matched field will be stored.matched_value_len
: If thematched_field
is notNULL
, the length of the value of the matched field will be stored.capture_names
: A pointer to an array of pointers to the capture names, each element is a non-C-style string pointer.capture_names_len
: A pointer to an array of the length of each capture name.capture_values
: A pointer to an array of pointers to the capture values, each element is a non-C-style string pointer.capture_values_len
: A pointer to an array of the length of each capture value.
§Returns
Returns the number of captures that are stored in the context.
§Lifetimes
The string pointers stored in matched_value
, capture_names
, and capture_values
might be invalidated if any of the following operations are happened:
- The
context
was deallocated. - The
context
was reset bycontext_reset
.
§Panics
This function will panic if the matched_field
is not a valid UTF-8 string.
§Safety
Violating any of the following constraints will result in undefined behavior:
context
must be a valid pointer returned bycontext_new
, must be passed to [router_execute
] before calling this function, and must not be reset bycontext_reset
before calling this function.- If
uuid_hex
is notNULL
,uuid_hex
must be valid to read and write for16 * size_of::<u8>()
bytes, and it must be properly aligned. - If
matched_field
is notNULL
,matched_field
must be a vlaid pointer to a C-style string, must be properly aligned, and must not have ‘\0’ in the middle. - If
matched_value
is notNULL
,matched_value
must be valid to read and write formem::size_of::<*const u8>()
bytes, and it must be properly aligned. - If
matched_value
is notNULL
,matched_value_len
must be valid to read and write forsize_of::<usize>()
bytes, and it must be properly aligned. - If
uuid_hex
is notNULL
,capture_names
must be valid to read and write for<captures> * size_of::<*const u8>()
bytes, and it must be properly aligned. - If
uuid_hex
is notNULL
,capture_names_len
must be valid to read and write for<captures> * size_of::<usize>()
bytes, and it must be properly aligned. - If
uuid_hex
is notNULL
,capture_values
must be valid to read and write for<captures> * size_of::<*const u8>()
bytes, and it must be properly aligned. - If
uuid_hex
is notNULL
,capture_values_len
must be valid to read and write for<captures> * size_of::<usize>()
bytes, and it must be properly aligned.
Note: You should get the <captures>
by calling this function and set every pointer
except the context
to NULL
to get the number of captures.