pub struct GuardedOwnedView<V> { /* private fields */ }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>
impl<V: ViewLifetimeParametric> GuardedOwnedView<V>
Sourcepub fn decode(
source: &[u8],
options: &DecodeOptions,
) -> Result<Self, GuardedViewError>
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.
Sourcepub fn from_owned(
message: &V::Owned,
options: &DecodeOptions,
) -> Result<Self, GuardedViewError>
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>
impl<V: ViewReborrow> GuardedOwnedView<V>
Sourcepub fn view(&self) -> &V::Reborrowed<'_>
pub fn view(&self) -> &V::Reborrowed<'_>
Borrow the decoded view for as long as this owner is borrowed.
Sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
Borrow the private encoded bytes without transferring ownership.
Sourcepub fn to_owned_message(&self) -> Result<V::Owned, DecodeError>
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.