#[no_mangle]
pub unsafe extern "C" fn context_add_value(
context: &mut Context<'_>,
field: *const i8,
value: &CValue,
errbuf: *mut u8,
errbuf_len: *mut usize,
) -> bool
Expand description
Add a value associated with a field to the context. This is useful when you want to match a value against a field in the schema.
§Arguments
context
: a pointer to theContext
object.field
: the C-style string representing the field name.value
: the value to be added to the context.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 value 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 value could not be added to the context,
such as when a String value is not a valid UTF-8 string.
§Panics
This function will panic if the provided value does not match the schema.
§Safety
Violating any of the following constraints will result in undefined behavior:
context
must be a valid pointer returned bycontext_new
.field
must be a valid pointer to a C-style string, must be properply aligned, and must not have ‘\0’ in the middle.value
must be a valid pointer to aCValue
.errbuf
must be valid to read and write forerrbuf_len * size_of::<u8>()
bytes, and it must be properly aligned.errbuf_len
must be vlaid to read and write forsize_of::<usize>()
bytes, and it must be properly aligned.