Skip to main content

MemBio

Struct MemBio 

Source
pub struct MemBio { /* private fields */ }
Expand description

A writable, growable in-memory BIO.

Data written to this BIO accumulates in an internal buffer managed by OpenSSL. After writing, data() returns a borrowed slice without copying.

Implementations§

Source§

impl MemBio

Source

pub fn new() -> Result<Self, ErrorStack>

Create a new empty writable BIO_s_mem() BIO.

§Errors

Returns Err if OpenSSL cannot allocate the BIO.

Source

pub fn write(&mut self, data: &[u8]) -> Result<(), ErrorStack>

Write bytes into the BIO’s internal buffer.

§Errors

Returns Err if the write fails.

Source

pub fn data(&self) -> &[u8]

Borrow the current contents of the BIO’s buffer as a &[u8].

The slice is valid until the next write operation or until self is dropped. This is a zero-copy view — no allocation occurs.

Source

pub fn into_vec(self) -> Vec<u8>

Move the buffer contents into a freshly allocated Vec<u8>.

Prefer data() when a borrow suffices.

Trait Implementations§

Source§

impl Drop for MemBio

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for MemBio

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.