Struct Content
pub struct Content(/* private fields */);Expand description
A piece of document content.
Implementations§
§impl Content
impl Content
pub fn new<T>(elem: T) -> Contentwhere
T: NativeElement,
pub fn new<T>(elem: T) -> Contentwhere
T: NativeElement,
Creates a new content from an element.
pub fn span(&self) -> Span
pub fn span(&self) -> Span
Get the span of the content.
pub fn labelled_at(&self) -> Span
pub fn labelled_at(&self) -> Span
Get the span where the label is attached.
pub fn located(self, loc: Location) -> Content
pub fn located(self, loc: Location) -> Content
Assigns a location to the content.
This identifies the content and e.g. makes it linkable by
.linked(Destination::Location(loc)).
Useful in combination with [Location::variant].
pub fn set_location(&mut self, location: Location)
pub fn set_location(&mut self, location: Location)
Set the location of the content.
pub fn is_guarded(&self, index: RecipeIndex) -> bool
pub fn is_guarded(&self, index: RecipeIndex) -> bool
Check whether a show rule recipe is disabled.
pub fn guarded(self, index: RecipeIndex) -> Content
pub fn guarded(self, index: RecipeIndex) -> Content
Disable a show rule recipe.
pub fn is_prepared(&self) -> bool
pub fn is_prepared(&self) -> bool
Whether this content has already been prepared.
pub fn mark_prepared(&mut self)
pub fn mark_prepared(&mut self)
Mark this content as prepared.
pub fn get(
&self,
id: u8,
styles: Option<StyleChain<'_>>,
) -> Result<Value, FieldAccessError>
pub fn get( &self, id: u8, styles: Option<StyleChain<'_>>, ) -> Result<Value, FieldAccessError>
Get a field by ID.
This is the preferred way to access fields. However, you can only use it
if you have set the field IDs yourself or are using the field IDs
generated by the #[elem] macro.
pub fn get_by_name(&self, name: &str) -> Result<Value, FieldAccessError>
pub fn get_by_name(&self, name: &str) -> Result<Value, FieldAccessError>
Get a field by name.
If you have access to the field IDs of the element, use Self::get
instead.
pub fn field(&self, id: u8) -> Result<Value, EcoString>
pub fn field(&self, id: u8) -> Result<Value, EcoString>
Get a field by ID, returning a missing field error if it does not exist.
This is the preferred way to access fields. However, you can only use it
if you have set the field IDs yourself or are using the field IDs
generated by the #[elem] macro.
pub fn field_by_name(&self, name: &str) -> Result<Value, EcoString>
pub fn field_by_name(&self, name: &str) -> Result<Value, EcoString>
Get a field by name, returning a missing field error if it does not exist.
If you have access to the field IDs of the element, use Self::field
instead.
pub fn materialize(&mut self, styles: StyleChain<'_>)
pub fn materialize(&mut self, styles: StyleChain<'_>)
Resolve all fields with the styles and save them in-place.
pub fn sequence(iter: impl IntoIterator<Item = Content>) -> Content
pub fn sequence(iter: impl IntoIterator<Item = Content>) -> Content
Create a new sequence element from multiples elements.
pub fn is<T>(&self) -> boolwhere
T: NativeElement,
pub fn is<T>(&self) -> boolwhere
T: NativeElement,
Whether the contained element is of type T.
pub fn to_packed<T>(&self) -> Option<&Packed<T>>where
T: NativeElement,
pub fn to_packed<T>(&self) -> Option<&Packed<T>>where
T: NativeElement,
Downcasts the element to a packed value.
pub fn to_packed_mut<T>(&mut self) -> Option<&mut Packed<T>>where
T: NativeElement,
pub fn to_packed_mut<T>(&mut self) -> Option<&mut Packed<T>>where
T: NativeElement,
Downcasts the element to a mutable packed value.
pub fn into_packed<T>(self) -> Result<Packed<T>, Content>where
T: NativeElement,
pub fn into_packed<T>(self) -> Result<Packed<T>, Content>where
T: NativeElement,
Downcasts the element into an owned packed value.
pub fn unpack<T>(self) -> Result<T, Content>where
T: NativeElement,
pub fn unpack<T>(self) -> Result<T, Content>where
T: NativeElement,
Extract the raw underlying element.
pub fn can<C>(&self) -> boolwhere
C: 'static + ?Sized,
pub fn can<C>(&self) -> boolwhere
C: 'static + ?Sized,
Whether the contained element has the given capability.
pub fn with<C>(&self) -> Option<&C>where
C: 'static + ?Sized,
pub fn with<C>(&self) -> Option<&C>where
C: 'static + ?Sized,
Cast to a trait object if the contained element has the given capability.
pub fn with_mut<C>(&mut self) -> Option<&mut C>where
C: 'static + ?Sized,
pub fn with_mut<C>(&mut self) -> Option<&mut C>where
C: 'static + ?Sized,
Cast to a mutable trait object if the contained element has the given capability.
pub fn sequence_recursive_for_each<'a>(
&'a self,
f: &mut impl FnMut(&'a Content),
)
pub fn sequence_recursive_for_each<'a>( &'a self, f: &mut impl FnMut(&'a Content), )
Also auto expands sequence of sequences into flat sequence
pub fn styled_with_recipe(
self,
engine: &mut Engine<'_>,
context: Tracked<'_, Context<'_>>,
recipe: Recipe,
) -> Result<Content, EcoVec<SourceDiagnostic>>
pub fn styled_with_recipe( self, engine: &mut Engine<'_>, context: Tracked<'_, Context<'_>>, recipe: Recipe, ) -> Result<Content, EcoVec<SourceDiagnostic>>
Style this content with a recipe, eagerly applying it if possible.
pub fn set<E, const I: u8>(
self,
field: Field<E, I>,
value: <E as SettableProperty<I>>::Type,
) -> Contentwhere
E: SettableProperty<I>,
<E as SettableProperty<I>>::Type: Debug + Clone + Hash + Send + Sync + 'static,
pub fn set<E, const I: u8>(
self,
field: Field<E, I>,
value: <E as SettableProperty<I>>::Type,
) -> Contentwhere
E: SettableProperty<I>,
<E as SettableProperty<I>>::Type: Debug + Clone + Hash + Send + Sync + 'static,
Sets a style property on the content.
pub fn styled_with_map(self, styles: Styles) -> Content
pub fn styled_with_map(self, styles: Styles) -> Content
Style this content with a full style map.
pub fn style_in_place(&mut self, styles: Styles)
pub fn style_in_place(&mut self, styles: Styles)
Style this content with a full style map in-place.
pub fn query_first_naive(&self, selector: &Selector) -> Option<Content>
pub fn query_first_naive(&self, selector: &Selector) -> Option<Content>
Queries the content tree for the first element that match the given selector.
This is a naive hack because contextual content and elements produced
in show rules will not be included in the results. It’s used should
be avoided.
pub fn plain_text(&self) -> EcoString
pub fn plain_text(&self) -> EcoString
Extracts the plain text of this content.
pub fn traverse<F, B>(&self, f: &mut F) -> ControlFlow<B>
pub fn traverse<F, B>(&self, f: &mut F) -> ControlFlow<B>
Traverse this content.
§impl Content
impl Content
Trait Implementations§
§impl AddAssign<&Content> for Content
impl AddAssign<&Content> for Content
§fn add_assign(&mut self, rhs: &Content)
fn add_assign(&mut self, rhs: &Content)
+= operation. Read more§impl AddAssign for Content
impl AddAssign for Content
§fn add_assign(&mut self, rhs: Content)
fn add_assign(&mut self, rhs: Content)
+= operation. Read more§impl<T> From<T> for Contentwhere
T: NativeElement,
impl<T> From<T> for Contentwhere
T: NativeElement,
§impl FromValue for Content
impl FromValue for Content
§fn from_value(value: Value) -> Result<Content, HintedString>
fn from_value(value: Value) -> Result<Content, HintedString>
Self.§impl NativeScope for Content
impl NativeScope for Content
§fn constructor() -> Option<&'static NativeFuncData>
fn constructor() -> Option<&'static NativeFuncData>
§impl NativeType for Content
impl NativeType for Content
§impl Reflect for Content
impl Reflect for Content
§fn error(found: &Value) -> HintedString
fn error(found: &Value) -> HintedString
§impl Serialize for Content
impl Serialize for Content
§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,
impl StructuralPartialEq for Content
Auto Trait Implementations§
impl Freeze for Content
impl RefUnwindSafe for Content
impl Send for Content
impl Sync for Content
impl Unpin for Content
impl UnwindSafe for Content
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
§fn from_value(value: Spanned<Value>) -> Result<T, HintedString>
fn from_value(value: Spanned<Value>) -> Result<T, HintedString>
Self.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoResult for Twhere
T: IntoValue,
impl<T> IntoResult for Twhere
T: IntoValue,
§fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more