pub struct OwnedNodeRef { /* private fields */ }Expand description
A decoded node that owns its decompressed buffer. The inner NodeRef
borrows string/byte payloads directly from the buffer, avoiding copies.
Container allocations (attribute Vec, child Vec) still occur during decode.
Wrap in Arc<OwnedNodeRef> for cheap sharing across handlers.
Implementations§
Source§impl OwnedNodeRef
impl OwnedNodeRef
Sourcepub fn new(buffer: impl Into<Bytes>) -> Result<OwnedNodeRef, BinaryError>
pub fn new(buffer: impl Into<Bytes>) -> Result<OwnedNodeRef, BinaryError>
Decode a node from an owned buffer. The buffer should be the raw
binary-protocol bytes (after decompression, without the leading
format byte which unpack already strips).
Sourcepub fn to_owned_node(&self) -> Node
pub fn to_owned_node(&self) -> Node
Convert to an owned Node, cloning all data out of the buffer.
Use sparingly — this is the allocation path that yoke is designed to avoid.
Sourcepub fn slice_bytes(&self, slice: &[u8]) -> Bytes
pub fn slice_bytes(&self, slice: &[u8]) -> Bytes
Return a zero-copy Bytes sub-view for a slice that borrows from this
node’s backing buffer. Panics if slice does not point within the buffer.
Sourcepub fn attrs(&self) -> AttrParserRef<'_>
pub fn attrs(&self) -> AttrParserRef<'_>
Get an attribute parser for this node.
Sourcepub fn get_optional_child(&self, tag: &str) -> Option<&NodeRef<'_>>
pub fn get_optional_child(&self, tag: &str) -> Option<&NodeRef<'_>>
Find a child node by tag.
Sourcepub fn get_optional_child_by_tag(&self, tags: &[&str]) -> Option<&NodeRef<'_>>
pub fn get_optional_child_by_tag(&self, tags: &[&str]) -> Option<&NodeRef<'_>>
Find a child by traversing a path of tags.
Sourcepub fn get_children_by_tag<'b>(
&'b self,
tag: &'b str,
) -> impl Iterator<Item = &'b NodeRef<'b>>
pub fn get_children_by_tag<'b>( &'b self, tag: &'b str, ) -> impl Iterator<Item = &'b NodeRef<'b>>
Get children matching a tag.
Sourcepub fn content_bytes(&self) -> Option<&[u8]>
pub fn content_bytes(&self) -> Option<&[u8]>
Zero-copy byte content, if this node has Bytes content.
Sourcepub fn content_str(&self) -> Option<&str>
pub fn content_str(&self) -> Option<&str>
Zero-copy string content, if this node has String content.
Sourcepub fn content_nodes(&self) -> Option<&[NodeRef<'_>]>
pub fn content_nodes(&self) -> Option<&[NodeRef<'_>]>
Child nodes from content, if this node has Nodes content.
Sourcepub fn content_as_string(&self) -> Option<CompactString>
pub fn content_as_string(&self) -> Option<CompactString>
Extract text content, handling both String and Bytes (lossy UTF-8).
Trait Implementations§
Source§impl Debug for OwnedNodeRef
impl Debug for OwnedNodeRef
Source§impl Serialize for OwnedNodeRef
Available on crate feature serde only.
impl Serialize for OwnedNodeRef
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl !Freeze for OwnedNodeRef
impl RefUnwindSafe for OwnedNodeRef
impl Send for OwnedNodeRef
impl Sync for OwnedNodeRef
impl Unpin for OwnedNodeRef
impl UnsafeUnpin for OwnedNodeRef
impl UnwindSafe for OwnedNodeRef
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more