summaryrefslogtreecommitdiff
path: root/src/model/content.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/content.rs')
-rw-r--r--src/model/content.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/model/content.rs b/src/model/content.rs
index 619793ec..c2c70f9d 100644
--- a/src/model/content.rs
+++ b/src/model/content.rs
@@ -39,16 +39,19 @@ enum Attr {
impl Content {
/// Create an empty element.
+ #[tracing::instrument()]
pub fn new(func: ElemFunc) -> Self {
Self { func, attrs: EcoVec::new() }
}
/// Create empty content.
+ #[tracing::instrument()]
pub fn empty() -> Self {
Self::new(SequenceElem::func())
}
/// Create a new sequence element from multiples elements.
+ #[tracing::instrument(skip_all)]
pub fn sequence(iter: impl IntoIterator<Item = Self>) -> Self {
let mut iter = iter.into_iter();
let Some(first) = iter.next() else { return Self::empty() };
@@ -91,6 +94,7 @@ impl Content {
}
/// Access the child and styles.
+ #[tracing::instrument(skip_all)]
pub fn to_styled(&self) -> Option<(&Content, &Styles)> {
if !self.is::<StyledElem>() {
return None;
@@ -116,6 +120,7 @@ impl Content {
/// Cast to a trait object if the contained element has the given
/// capability.
+ #[tracing::instrument(skip_all)]
pub fn with<C>(&self) -> Option<&C>
where
C: ?Sized + 'static,
@@ -127,6 +132,7 @@ impl Content {
/// Cast to a mutable trait object if the contained element has the given
/// capability.
+ #[tracing::instrument(skip_all)]
pub fn with_mut<C>(&mut self) -> Option<&mut C>
where
C: ?Sized + 'static,
@@ -174,6 +180,7 @@ impl Content {
}
/// Access a field on the content.
+ #[tracing::instrument(skip_all)]
pub fn field(&self, name: &str) -> Option<Value> {
if let (Some(iter), "children") = (self.to_sequence(), name) {
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
@@ -360,6 +367,7 @@ impl Content {
/// Queries the content tree for all elements that match the given selector.
///
/// Elements produced in `show` rules will not be included in the results.
+ #[tracing::instrument(skip_all)]
pub fn query(&self, selector: Selector) -> Vec<&Content> {
let mut results = Vec::new();
self.traverse(&mut |element| {