pub fn match_result_code_with_expected_bytes<F, T>(
result_code: i32,
expected_num_bytes: usize,
on_success: F,
) -> Result<T>where
F: FnOnce() -> T,Expand description
Evaluates a result code against an expected number of bytes and executes a closure on exact match.
§Arguments
result_code- An integer representing the operation result codeexpected_num_bytes- The exact number of bytes expected to have been writtenon_success- A closure that will be executed if the result code matches expected bytes
§Type Parameters
F- The type of the closureT- The return type of the closure
§Returns
Returns a Result<T> where:
Ok(T)- Contains the value returned by the closure if result_code matches expected_num_bytesErr(InternalError)- If result_code is non-negative but doesn’t match expected bytesErr(Error)- For negative result codes
§Note
This function requires an exact match between the result code and expected byte count, making it suitable for operations where the exact amount of data written is critical.