pub fn resize(&mut self, len: usize) -> Result<()> {
        /*
         * memfd_secret fds are *not* resizable! In fact, doing so might panic the kernel:
         * https://patchwork.kernel.org/project/linux-mm/patch/20220324210909.1843814-1-axelrasmussen@google.com/
         *
         * So, construct a new one, copy into it, and then replace ourself with it.
         */

        let mut next = Secret::with_len(len)?;

        {
            let copy_len = std::cmp::min(self.len, len);
            let (to_copy, to_zero) = unsafe { next.as_mut_slice() }.split_at_mut(copy_len);

            to_copy.copy_from_slice(unsafe { self.as_slice() }.split_at(copy_len).0);
            to_zero.fill(0);
        }

        self.clear()?;
        *self = std::mem::take(&mut next);
        Ok(())
    }
/// Resize the buffer's length in bytes. If the new length is smaller, the existing data is
/// truncated. If the new length is larger, the new bytes will be zeros.
Resize the buffer's length in bytes. If the new length is smaller, the existing data is
truncated. If the new length is larger, the new bytes will be zeros.
Resize the buffer ' s length in bytes . If the new length is smaller the existing data is truncated . If the new length is larger the new bytes will be zeros .
pub fn resize(&mut self, len: usize) -> Result<()> {
        /*
         * memfd_secret fds are *not* resizable! In fact, doing so might panic the kernel:
         * https://patchwork.kernel.org/project/linux-mm/patch/20220324210909.1843814-1-axelrasmussen@google.com/
         *
         * So, construct a new one, copy into it, and then replace ourself with it.
         */
        let mut next = Secret::with_len(len)?;
        {
            let copy_len = std::cmp::min(self.len, len);
            let (to_copy, to_zero) = unsafe { next.as_mut_slice() }.split_at_mut(copy_len);
            to_copy.copy_from_slice(unsafe { self.as_slice() }.split_at(copy_len).0);
            to_zero.fill(0);
        }
        self.clear()?;
        *self = std::mem::take(&mut next);
        Ok(())
    }
pub fn resize ( & mut self , len : usize ) -> Result < ( ) > { /*
         * memfd_secret fds are *not* resizable! In fact, doing so might panic the kernel:
         * https://patchwork.kernel.org/project/linux-mm/patch/20220324210909.1843814-1-axelrasmussen@google.com/
         *
         * So, construct a new one, copy into it, and then replace ourself with it.
         */ let mut next = Secret :: with_len ( len ) ? ; { let copy_len = std :: cmp :: min ( self . len , len ) ; let ( to_copy , to_zero ) = unsafe { next . as_mut_slice ( ) } . split_at_mut ( copy_len ) ; to_copy . copy_from_slice ( unsafe { self . as_slice ( ) } . split_at ( copy_len ) . 0 ) ; to_zero . fill ( 0 ) ; } self . clear ( ) ? ; * self = std :: mem :: take ( & mut next ) ; Ok ( ( ) ) }
Resize the buffer's length in bytes.
Resize the buffer ' s length in bytes .
&mut self
len
usize
&mut self
len
usize