atc_router::ffi::router

Function router_add_matcher

Source
#[no_mangle]
pub unsafe extern "C" fn router_add_matcher(
    router: &mut Router<'_>,
    priority: usize,
    uuid: *const i8,
    atc: *const i8,
    errbuf: *mut u8,
    errbuf_len: *mut usize,
) -> bool
Expand description

Add a new matcher to the router.

§Arguments

  • router: a pointer to the Router object returned by router_new.
  • priority: the priority of the matcher, higher value means higher priority, and the matcher with the highest priority will be executed first.
  • uuid: the C-style string representing the UUID of the matcher.
  • atc: the C-style string representing the ATC expression.
  • errbuf: a buffer to store the error message.
  • errbuf_len: a pointer to the length of the error message buffer.

§Returns

Returns true if the matcher was added successfully, otherwise false, and the error message will be stored in the errbuf, and the length of the error message will be stored in errbuf_len.

§Errors

This function will return false if the matcher could not be added to the router, such as duplicate UUID, and invalid ATC expression.

§Panics

This function will panic when:

  • uuid doesn’t point to a ASCII sequence representing a valid 128-bit UUID.
  • atc doesn’t point to a valid C-style string.

§Safety

Violating any of the following constraints will result in undefined behavior:

  • router must be a valid pointer returned by router_new.
  • uuid must be a valid pointer to a C-style string, must be properly aligned, and must not have ‘\0’ in the middle.
  • atc must be a valid pointer to a C-style string, must be properly aligned, and must not have ‘\0’ in the middle.
  • errbuf must be valid to read and write for errbuf_len * size_of::<u8>() bytes, and it must be properly aligned.
  • errbuf_len must be valid to read and write for size_of::<usize>() bytes, and it must be properly aligned.