pub fn reserve<'txn>(
        &'txn self,
        db: &Database<'txn>,
        key: impl AsRef<[u8]>,
        len: usize,
        flags: WriteFlags,
    ) -> Result<&'txn mut [u8]> {
        let key = key.as_ref();
        let key_val: ffi::MDBX_val = ffi::MDBX_val {
            iov_len: key.len(),
            iov_base: key.as_ptr() as *mut c_void,
        };
        let mut data_val: ffi::MDBX_val = ffi::MDBX_val {
            iov_len: len,
            iov_base: ptr::null_mut::<c_void>(),
        };
        unsafe {
            mdbx_result(txn_execute(&self.txn, |txn| {
                ffi::mdbx_put(
                    txn,
                    db.dbi(),
                    &key_val,
                    &mut data_val,
                    c_enum(flags.bits() | ffi::MDBX_RESERVE as u32),
                )
            }))?;
            Ok(slice::from_raw_parts_mut(
                data_val.iov_base as *mut u8,
                data_val.iov_len,
            ))
        }
    }
/// Returns a buffer which can be used to write a value into the item at the
/// given key and with the given length. The buffer must be completely
/// filled by the caller.
Returns a buffer which can be used to write a value into the item at the
given key and with the given length. The buffer must be completely
filled by the caller.
Returns a buffer which can be used to write a value into the item at the given key and with the given length . The buffer must be completely filled by the caller .
pub fn reserve<'txn>(
        &'txn self,
        db: &Database<'txn>,
        key: impl AsRef<[u8]>,
        len: usize,
        flags: WriteFlags,
    ) -> Result<&'txn mut [u8]> {
        let key = key.as_ref();
        let key_val: ffi::MDBX_val = ffi::MDBX_val {
            iov_len: key.len(),
            iov_base: key.as_ptr() as *mut c_void,
        };
        let mut data_val: ffi::MDBX_val = ffi::MDBX_val {
            iov_len: len,
            iov_base: ptr::null_mut::<c_void>(),
        };
        unsafe {
            mdbx_result(txn_execute(&self.txn, |txn| {
                ffi::mdbx_put(
                    txn,
                    db.dbi(),
                    &key_val,
                    &mut data_val,
                    c_enum(flags.bits() | ffi::MDBX_RESERVE as u32),
                )
            }))?;
            Ok(slice::from_raw_parts_mut(
                data_val.iov_base as *mut u8,
                data_val.iov_len,
            ))
        }
    }
pub fn reserve < ' txn > ( & ' txn self , db : & Database < ' txn > , key : impl AsRef < [ u8 ] > , len : usize , flags : WriteFlags , ) -> Result < & ' txn mut [ u8 ] > { let key = key . as_ref ( ) ; let key_val : ffi :: MDBX_val = ffi :: MDBX_val { iov_len : key . len ( ) , iov_base : key . as_ptr ( ) as * mut c_void , } ; let mut data_val : ffi :: MDBX_val = ffi :: MDBX_val { iov_len : len , iov_base : ptr :: null_mut :: < c_void > ( ) , } ; unsafe { mdbx_result ( txn_execute ( & self . txn , | txn | { ffi :: mdbx_put ( txn , db . dbi ( ) , & key_val , & mut data_val , c_enum ( flags . bits ( ) | ffi :: MDBX_RESERVE as u32 ) , ) } ) ) ? ; Ok ( slice :: from_raw_parts_mut ( data_val . iov_base as * mut u8 , data_val . iov_len , ) ) } }
Returns a buffer which can be used to write a value into the item at the
given key and with the given length.
Returns a buffer which can be used to write a value into the item at the given key and with the given length .
&'txn self
db
&Database<'txn>
key
impl AsRef<[u8]>
len
usize
flags
WriteFlags