Remove check macro

Can be replaced by a simple function and ? operator.
This commit is contained in:
gwenn
2021-07-04 15:52:31 +02:00
parent 10da56788c
commit 7056e656ac
6 changed files with 65 additions and 77 deletions

View File

@@ -4,6 +4,7 @@ use std::convert::TryFrom;
use std::mem::MaybeUninit;
use std::slice::from_raw_parts_mut;
use crate::error::check;
use crate::ffi;
use crate::{Error, Result};
@@ -44,15 +45,14 @@ impl<'conn> Blob<'conn> {
// losslessly converted to i32, since `len` came from an i32.
// Sanity check the above.
debug_assert!(i32::try_from(write_start).is_ok() && i32::try_from(buf.len()).is_ok());
unsafe {
check!(ffi::sqlite3_blob_write(
check(unsafe {
ffi::sqlite3_blob_write(
self.blob,
buf.as_ptr() as *const _,
buf.len() as i32,
write_start as i32,
));
}
Ok(())
)
})
}
/// An alias for `write_at` provided for compatibility with the conceptually
@@ -151,12 +151,12 @@ impl<'conn> Blob<'conn> {
debug_assert!(i32::try_from(read_len).is_ok());
unsafe {
check!(ffi::sqlite3_blob_read(
check(ffi::sqlite3_blob_read(
self.blob,
buf.as_mut_ptr() as *mut _,
read_len as i32,
read_start as i32,
));
))?;
Ok(from_raw_parts_mut(buf.as_mut_ptr() as *mut u8, read_len))
}