pub fn unwrap<M: AsRef<[u8]>>(&mut self, wrapped: M) -> Result<Vec<u8>> {
        let (wrapped_ptr, wrapped_len) = into_raw_parts(wrapped.as_ref());

        let mut message = Vec::new();
        let mut message_len = 0;

        unsafe {
            let status = secure_session_unwrap(
                self.session_ctx,
                wrapped_ptr as *const c_void,
                wrapped_len,
                ptr::null_mut(),
                &mut message_len,
            );
            let error = Error::from_session_status(status);
            if error.kind() != ErrorKind::BufferTooSmall {
                return Err(error);
            }
        }

        message.reserve(message_len);

        unsafe {
            let status = secure_session_unwrap(
                self.session_ctx,
                wrapped_ptr as *const c_void,
                wrapped_len,
                message.as_mut_ptr() as *mut c_void,
                &mut message_len,
            );
            let error = Error::from_session_status(status);
            if error.kind() != ErrorKind::Success {
                return Err(error);
            }
            debug_assert!(message_len <= message.capacity());
            message.set_len(message_len);
        }

        Ok(message)
    }
/// Unwraps a message and returns it.
///
/// Unwraps a message previously [wrapped] by the remote peer.
///
/// This method will fail if a secure connection has not been established yet.
///
/// [wrapped]: struct.SecureSession.html#method.wrap
Unwraps a message and returns it.
Unwraps a message previously [wrapped] by the remote peer.

This method will fail if a secure connection has not been established yet.


Unwraps a message and returns it . Unwraps a message previously [ wrapped ] by the remote peer . This method will fail if a secure connection has not been established yet .
pub fn unwrap<M: AsRef<[u8]>>(&mut self, wrapped: M) -> Result<Vec<u8>> {
        let (wrapped_ptr, wrapped_len) = into_raw_parts(wrapped.as_ref());
        let mut message = Vec::new();
        let mut message_len = 0;
        unsafe {
            let status = secure_session_unwrap(
                self.session_ctx,
                wrapped_ptr as *const c_void,
                wrapped_len,
                ptr::null_mut(),
                &mut message_len,
            );
            let error = Error::from_session_status(status);
            if error.kind() != ErrorKind::BufferTooSmall {
                return Err(error);
            }
        }
        message.reserve(message_len);
        unsafe {
            let status = secure_session_unwrap(
                self.session_ctx,
                wrapped_ptr as *const c_void,
                wrapped_len,
                message.as_mut_ptr() as *mut c_void,
                &mut message_len,
            );
            let error = Error::from_session_status(status);
            if error.kind() != ErrorKind::Success {
                return Err(error);
            }
            debug_assert!(message_len <= message.capacity());
            message.set_len(message_len);
        }
        Ok(message)
    }
pub fn unwrap < M : AsRef < [ u8 ] > > ( & mut self , wrapped : M ) -> Result < Vec < u8 > > { let ( wrapped_ptr , wrapped_len ) = into_raw_parts ( wrapped . as_ref ( ) ) ; let mut message = Vec :: new ( ) ; let mut message_len = 0 ; unsafe { let status = secure_session_unwrap ( self . session_ctx , wrapped_ptr as * const c_void , wrapped_len , ptr :: null_mut ( ) , & mut message_len , ) ; let error = Error :: from_session_status ( status ) ; if error . kind ( ) != ErrorKind :: BufferTooSmall { return Err ( error ) ; } } message . reserve ( message_len ) ; unsafe { let status = secure_session_unwrap ( self . session_ctx , wrapped_ptr as * const c_void , wrapped_len , message . as_mut_ptr ( ) as * mut c_void , & mut message_len , ) ; let error = Error :: from_session_status ( status ) ; if error . kind ( ) != ErrorKind :: Success { return Err ( error ) ; } debug_assert ! ( message_len message capacity ( ) ) ; message . set_len ( message_len ) ; } Ok ( message ) }
Unwraps a message and returns it.
Unwraps a message and returns it .
&mut self
wrapped
M
&mut self
wrapped
M