Struct redact_composer_core::render::context::CtxQuery
source · pub struct CtxQuery<'a, S: Element, F: Fn(&S) -> bool> { /* private fields */ }
Expand description
A context query builder. Initiate a query via CompositionContext::find
.
Implementations§
source§impl<'a, S: Element, F: Fn(&S) -> bool> CtxQuery<'a, S, F>
impl<'a, S: Element, F: Fn(&S) -> bool> CtxQuery<'a, S, F>
sourcepub fn with_timing<R: RangeBounds<i32>>(
self,
relation: TimingRelation,
timing: &R
) -> Self
pub fn with_timing<R: RangeBounds<i32>>( self, relation: TimingRelation, timing: &R ) -> Self
Restrict the search to segments matching a given TimingRelation
.
sourcepub fn within<S2: Element>(self) -> Self
pub fn within<S2: Element>(self) -> Self
Restrict the search to descendent segments a given Element
type. This does
not in itself impose any timing constraints for the search – for that, use
with_timing
.
sourcepub fn within_ancestor<S2: Element>(self) -> Self
pub fn within_ancestor<S2: Element>(self) -> Self
Restrict the search to segments generated within the initiator’s ancestor of the
given Element
. This does not in itself impose any timing constraints for the
search – for that, use with_timing
.
sourcepub fn matching(
self,
where_fn: impl Fn(&S) -> bool
) -> CtxQuery<'a, S, impl Fn(&S) -> bool>
pub fn matching( self, where_fn: impl Fn(&S) -> bool ) -> CtxQuery<'a, S, impl Fn(&S) -> bool>
Restrict the search to segments matching the supplied closure.
sourcepub fn get(self) -> Option<SegmentRef<'a, S>>
pub fn get(self) -> Option<SegmentRef<'a, S>>
Runs the context query, and returns a single optional result, or None
if none are found.
sourcepub fn get_all(self) -> Option<Vec<SegmentRef<'a, S>>>
pub fn get_all(self) -> Option<Vec<SegmentRef<'a, S>>>
Runs the context query, and returns all results, or None
if none are found.
sourcepub fn get_at_least(
self,
min_requested: usize
) -> Option<Vec<SegmentRef<'a, S>>>
pub fn get_at_least( self, min_requested: usize ) -> Option<Vec<SegmentRef<'a, S>>>
Runs the context query. Returns all results if at least min_requested
results are found,
otherwise None
is returned.
sourcepub fn require(self) -> Result<SegmentRef<'a, S>>
pub fn require(self) -> Result<SegmentRef<'a, S>>
Runs the context query, and returns a single result, or MissingContext
error if none are found.
sourcepub fn require_all(self) -> Result<Vec<SegmentRef<'a, S>>>
pub fn require_all(self) -> Result<Vec<SegmentRef<'a, S>>>
Runs the context query, and returns all results, or MissingContext
error if none are found.
sourcepub fn require_at_least(
self,
min_requested: usize
) -> Result<Vec<SegmentRef<'a, S>>>
pub fn require_at_least( self, min_requested: usize ) -> Result<Vec<SegmentRef<'a, S>>>
Runs the context query. If at least min_requested
results are found they are returned,
otherwise a MissingContext
error is returned.