Struct 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>

Source

pub fn with_timing<R: RangeBounds<i32>>( self, relation: TimingRelation, timing: R, ) -> Self

Restrict the search to segments matching a given TimingRelation.

Source

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.

Source

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.

Source

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.

Source

pub fn get(self) -> Option<SegmentRef<'a, S>>

Runs the context query, and returns a single optional result, or None if none are found.

Source

pub fn get_all(self) -> Option<Vec<SegmentRef<'a, S>>>

Runs the context query, and returns all results, or None if none are found.

Source

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.

Source

pub fn require(self) -> Result<SegmentRef<'a, S>>

Runs the context query, and returns a single result, or MissingContext error if none are found.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a, S: Debug + Element, F: Debug + Fn(&S) -> bool> Debug for CtxQuery<'a, S, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S, F> Freeze for CtxQuery<'a, S, F>
where F: Freeze,

§

impl<'a, S, F> !RefUnwindSafe for CtxQuery<'a, S, F>

§

impl<'a, S, F> !Send for CtxQuery<'a, S, F>

§

impl<'a, S, F> !Sync for CtxQuery<'a, S, F>

§

impl<'a, S, F> Unpin for CtxQuery<'a, S, F>
where F: Unpin, S: Unpin,

§

impl<'a, S, F> !UnwindSafe for CtxQuery<'a, S, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V