pub struct StaticText<'a, S> {
pub text: &'a str,
pub rectangle: Rectangle,
pub character_style: S,
pub alignment: Alignment,
pub baseline: Baseline,
}Expand description
StaticText drawable.
A text drawable can be used to draw text to a draw target.
See the module-level documentation for more information about text drawables and examples.
Fields§
§text: &'a strThe string.
rectangle: RectangleThe position.
character_style: SThe character style.
alignment: AlignmentHorizontal text alignment.
baseline: BaselineText baseline.
Implementations§
Source§impl<'a, S> StaticText<'a, S>
impl<'a, S> StaticText<'a, S>
Sourcepub const fn new(
text: &'a str,
rectangle: Rectangle,
character_style: S,
) -> Self
pub const fn new( text: &'a str, rectangle: Rectangle, character_style: S, ) -> Self
Creates a text drawable with the default text style.
Sourcepub const fn with_style(
text: &'a str,
rectangle: Rectangle,
character_style: S,
alignment: Alignment,
baseline: Baseline,
) -> Self
pub const fn with_style( text: &'a str, rectangle: Rectangle, character_style: S, alignment: Alignment, baseline: Baseline, ) -> Self
Creates a text drawable with the given alignment and baseline.
pub fn fill_with_style<C, D>(
&self,
style: PrimitiveStyle<C>,
target: &mut D,
) -> Result<Point, D::Error>where
C: PixelColor,
D: DrawTarget<Color = C>,
Source§impl<S: TextRenderer> StaticText<'_, S>
impl<S: TextRenderer> StaticText<'_, S>
pub fn clear<D>(&self, target: &mut D) -> Result<Point, D::Error>where
D: DrawTarget<Color = S::Color>,
pub fn clear_by_color<C, D>(
&self,
color: C,
target: &mut D,
) -> Result<Point, D::Error>where
C: PixelColor,
D: DrawTarget<Color = C>,
Trait Implementations§
Source§impl<'a, S: Clone> Clone for StaticText<'a, S>
impl<'a, S: Clone> Clone for StaticText<'a, S>
Source§fn clone(&self) -> StaticText<'a, S>
fn clone(&self) -> StaticText<'a, S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, S: Debug> Debug for StaticText<'a, S>
impl<'a, S: Debug> Debug for StaticText<'a, S>
Source§impl<S: TextRenderer> Drawable for StaticText<'_, S>
impl<S: TextRenderer> Drawable for StaticText<'_, S>
Source§type Color = <S as TextRenderer>::Color
type Color = <S as TextRenderer>::Color
The pixel color type.
Source§impl<'a, S: Hash> Hash for StaticText<'a, S>
impl<'a, S: Hash> Hash for StaticText<'a, S>
Source§impl<'a, S: Ord> Ord for StaticText<'a, S>
impl<'a, S: Ord> Ord for StaticText<'a, S>
Source§fn cmp(&self, other: &StaticText<'a, S>) -> Ordering
fn cmp(&self, other: &StaticText<'a, S>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a, S: PartialEq> PartialEq for StaticText<'a, S>
impl<'a, S: PartialEq> PartialEq for StaticText<'a, S>
Source§impl<'a, S: PartialOrd> PartialOrd for StaticText<'a, S>
impl<'a, S: PartialOrd> PartialOrd for StaticText<'a, S>
Source§impl<S: Clone> Transform for StaticText<'_, S>
impl<S: Clone> Transform for StaticText<'_, S>
impl<'a, S: Copy> Copy for StaticText<'a, S>
impl<'a, S: Eq> Eq for StaticText<'a, S>
impl<'a, S> StructuralPartialEq for StaticText<'a, S>
Auto Trait Implementations§
impl<'a, S> Freeze for StaticText<'a, S>where
S: Freeze,
impl<'a, S> RefUnwindSafe for StaticText<'a, S>where
S: RefUnwindSafe,
impl<'a, S> Send for StaticText<'a, S>where
S: Send,
impl<'a, S> Sync for StaticText<'a, S>where
S: Sync,
impl<'a, S> Unpin for StaticText<'a, S>where
S: Unpin,
impl<'a, S> UnwindSafe for StaticText<'a, S>where
S: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>,
Casts the value.
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>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>,
Casts the value.
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)
Casts the value.
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>,
Casts the value.
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
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.