pub fn get_variable_size_field_optional<const N: usize, F>(
field_code: i32,
host_fn: F,
) -> Result<Option<([u8; N], usize)>>Expand description
Optional variant of get_variable_size_field.
Returns None if the field is not found, otherwise behaves identically to the required variant.
§Type Parameters
N- The maximum size of the buffer (compile-time constant)F- The type of the host function closure
§Arguments
field_code- The field code identifying which field to retrievehost_fn- A closure that calls the appropriate host function
§Returns
Returns Result<Option<([u8; N], usize)>> where:
Ok(Some((buffer, len)))- If the field is presentOk(None)- If the field is not foundErr(Error)- If there’s an error retrieving the field
§Example
ⓘ
let result = get_variable_size_field_optional::<48>(
field_code,
|fc, buf, size| unsafe { get_current_ledger_obj_field(fc, buf, size) },
)?;