pub struct Owned<Y: for<'a> Yokeable<'a>> { /* private fields */ }Expand description
An owned, 'static, Send + Sync bundle of (backing bytes, parsed view).
Y is the view type with its lifetime set to 'static — e.g.
Owned<Pmt<'static>>, Owned<Sdt<'static>>,
Owned<DescriptorLoop<'static>>. The backing buffer is an Arc<[u8]>, so
Clone is a refcount bump and the view is shared, never re-parsed.
Construct one with Owned::try_new (fallible parse) or Owned::new
(infallible), then read the borrowing view with Owned::get.
Implementations§
Source§impl<Y: for<'a> Yokeable<'a>> Owned<Y>
impl<Y: for<'a> Yokeable<'a>> Owned<Y>
Sourcepub fn try_new<F, E>(bytes: Arc<[u8]>, parse: F) -> Result<Self, E>
pub fn try_new<F, E>(bytes: Arc<[u8]>, parse: F) -> Result<Self, E>
Parse bytes into a view and bundle the two into an Owned.
parse receives a borrow of the backing bytes and returns the borrowing
view (or an error). The borrow does not escape parse: yoke re-binds
the view’s lifetime to the Arc<[u8]> it now co-owns.
§Errors
Returns parse’s error verbatim if parsing fails.
Sourcepub fn new<F>(bytes: Arc<[u8]>, parse: F) -> Self
pub fn new<F>(bytes: Arc<[u8]>, parse: F) -> Self
Parse bytes into a view with an infallible parser and bundle them.
Sourcepub fn get(&self) -> &<Y as Yokeable<'_>>::Output
pub fn get(&self) -> &<Y as Yokeable<'_>>::Output
Borrow the parsed view. No re-parse; this is a field read.
Sourcepub fn backing_bytes(&self) -> &[u8] ⓘ
pub fn backing_bytes(&self) -> &[u8] ⓘ
The backing section bytes the view borrows from.