fn load_arm(suffix: u64, pwd: &str, storage: &mut Storage) -> Result<Self> {
        // read raw bytes
        let buf = storage.get_super_block(suffix)?;

        // read header
        let head = Head::deseri(&buf)?;

        // create crypto
        let crypto = Crypto::new(head.cost, head.cipher)?;

        // derive volume key and use it to decrypt body
        let pwd_hash = crypto.hash_pwd(pwd, &head.salt)?;
        let vkey = &pwd_hash.value;

        // read encryped body
        let mut comp_buf = crypto
            .decrypt_with_ad(&buf[Head::BYTES_LEN..], vkey, &Self::MAGIC)?
            .into_buf();
        let body_buf_len = comp_buf.get_u64_le() as usize;
        let body = Body::deseri(&comp_buf.bytes()[..body_buf_len])?;

        Ok(SuperBlk { head, body })
    }
// load a specific super block arm
load a specific super block arm
load a specific super block arm
fn load_arm(suffix: u64, pwd: &str, storage: &mut Storage) -> Result<Self> {
        // read raw bytes
        let buf = storage.get_super_block(suffix)?;
        // read header
        let head = Head::deseri(&buf)?;
        // create crypto
        let crypto = Crypto::new(head.cost, head.cipher)?;
        // derive volume key and use it to decrypt body
        let pwd_hash = crypto.hash_pwd(pwd, &head.salt)?;
        let vkey = &pwd_hash.value;
        // read encryped body
        let mut comp_buf = crypto
            .decrypt_with_ad(&buf[Head::BYTES_LEN..], vkey, &Self::MAGIC)?
            .into_buf();
        let body_buf_len = comp_buf.get_u64_le() as usize;
        let body = Body::deseri(&comp_buf.bytes()[..body_buf_len])?;
        Ok(SuperBlk { head, body })
    }
fn load_arm ( suffix : u64 , pwd : & str , storage : & mut Storage ) -> Result < Self > { // read raw bytes let buf = storage . get_super_block ( suffix ) ? ; // read header let head = Head :: deseri ( & buf ) ? ; // create crypto let crypto = Crypto :: new ( head . cost , head . cipher ) ? ; // derive volume key and use it to decrypt body let pwd_hash = crypto . hash_pwd ( pwd , & head . salt ) ? ; let vkey = & pwd_hash . value ; // read encryped body let mut comp_buf = crypto . decrypt_with_ad ( & buf [ Head :: BYTES_LEN .. ] , vkey , & Self :: MAGIC ) ? . into_buf ( ) ; let body_buf_len = comp_buf . get_u64_le ( ) as usize ; let body = Body :: deseri ( & comp_buf . bytes ( ) [ .. body_buf_len ] ) ? ; Ok ( SuperBlk { head , body } ) }
load a specific super block arm
load a specific super block arm
suffix
u64
pwd
&str
storage
&mut Storage
suffix
u64
pwd
&str
storage
&mut Storage