From 561ff979d574f496415c0499345d41da2e1f6e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Sun, 23 Apr 2023 14:33:56 +0200 Subject: Add instrumentation (Part 1) (#761) --- src/model/content.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/model/content.rs') 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) -> 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::() { 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(&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(&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 { 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| { -- cgit v1.2.3