///Read key-value pairs according to key.
///
/// # Example
///
/// ```no_run
/// # use ontio_std::runtime;
/// let key = "key";
/// let res = runtime::storage_read(key.as_bytes());
/// ```
///
Read key-value pairs according to key.
Read key - value pairs according to key .
pub fn storage_read(key: &[u8]) -> Option<Vec<u8>> {
    const INITIAL: usize = 32;
    let mut val = vec![0; INITIAL];
    let size = unsafe {
        env::ontio_storage_read(
            key.as_ptr(),
            key.len() as u32,
            val.as_mut_ptr(),
            val.len() as u32,
            0,
        )
    };
    if size == core::u32::MAX {
        return None;
    }
    let size = size as usize;
    val.resize(size, 0);
    if size > INITIAL {
        let value = &mut val[INITIAL..];
        debug_assert!(value.len() == size - INITIAL);
        unsafe {
            env::ontio_storage_read(
                key.as_ptr(),
                key.len() as u32,
                value.as_mut_ptr(),
                value.len() as u32,
                INITIAL as u32,
            )
        };
    }
    Some(val)
}
pub fn storage_read ( key : & [ u8 ] ) -> Option < Vec < u8 > > { const INITIAL : usize = 32 ; let mut val = vec ! [ 0 INITIAL ] ; let size = unsafe { env :: ontio_storage_read ( key . as_ptr ( ) , key . len ( ) as u32 , val . as_mut_ptr ( ) , val . len ( ) as u32 , 0 , ) } ; if size == core :: u32 :: MAX { return None ; } let size = size as usize ; val . resize ( size , 0 ) ; if size > INITIAL { let value = & mut val [ INITIAL .. ] ; debug_assert ! ( value len ( ) size INITIAL ) ; unsafe { env :: ontio_storage_read ( key . as_ptr ( ) , key . len ( ) as u32 , value . as_mut_ptr ( ) , value . len ( ) as u32 , INITIAL as u32 , ) } ; } Some ( val ) }
Read key-value pairs according to key.
Read key - value pairs according to key .
key
&[u8]
example
None
use ontio_std::runtime;
None