Skip to main content

GuardedOwnedView

Struct GuardedOwnedView 

Source
pub struct GuardedOwnedView<V> { /* private fields */ }
Available on crate feature zeroize only.
Expand description

An eager view with a private wire allocation that is wiped on drop.

This type exposes neither a clonable handle nor the underlying Bytes. The input passed to Self::decode remains the caller’s responsibility. For a message value, Self::from_owned encodes directly into the wiping allocation. It does not stage a second wire buffer. The view may own decoded values separately; those follow the view type’s own cleanup rules. The owner implements ZeroizeOnDrop only when the view does too.

ⓘ
use buffa::sensitive::GuardedOwnedView;
fn duplicate<V>(view: &GuardedOwnedView<V>) -> GuardedOwnedView<V> {
    (*view).clone()
}

Implementations§

Source§

impl<V: ViewLifetimeParametric> GuardedOwnedView<V>

Source

pub fn decode( source: &[u8], options: &DecodeOptions, ) -> Result<Self, GuardedViewError>

Copy a borrowed wire buffer into private storage and decode eagerly.

§Errors

Rejects over-limit input before allocating and returns an error on wire buffer reservation failure or malformed wire data.

Source

pub fn from_owned( message: &V::Owned, options: &DecodeOptions, ) -> Result<Self, GuardedViewError>

Encode directly into private storage, then decode eagerly.

§Errors

Returns an error if the encoded length exceeds a limit, reserving the wire buffer fails, the encoder’s actual length disagrees, or the view rejects the resulting bytes under the supplied options.

Source§

impl<V: ViewReborrow> GuardedOwnedView<V>

Source

pub fn view(&self) -> &V::Reborrowed<'_>

Borrow the decoded view for as long as this owner is borrowed.

Source

pub fn bytes(&self) -> &[u8] ⓘ

Borrow the private encoded bytes without transferring ownership.

Source

pub fn to_owned_message(&self) -> Result<V::Owned, DecodeError>

Convert fields to their owned representations without sharing the wire allocation. The message’s field types determine their own cleanup.

§Errors

Returns the view’s conversion error if its owned representation cannot be built.

Trait Implementations§

Source§

impl<V> Debug for GuardedOwnedView<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: ZeroizeOnDrop> ZeroizeOnDrop for GuardedOwnedView<V>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.