pub struct Text {
pub value: String,
pub marks: Vec<Mark>,
}Expand description
A text node containing content and optional formatting marks.
Text nodes are the leaf nodes in the content tree, containing actual text content along with formatting information.
§Example
use cdx_core::content::{Text, Mark};
// Plain text
let plain = Text::plain("Hello");
// Bold text
let bold = Text::with_marks("Important", vec![Mark::Bold]);
// Text with multiple marks
let bold_italic = Text::with_marks("Emphasis", vec![Mark::Bold, Mark::Italic]);Fields§
§value: StringThe text content.
marks: Vec<Mark>Formatting marks applied to this text.
Implementations§
Source§impl Text
impl Text
Sourcepub fn with_marks(value: impl Into<String>, marks: Vec<Mark>) -> Self
pub fn with_marks(value: impl Into<String>, marks: Vec<Mark>) -> Self
Create a text node with formatting marks.
Sourcepub fn link(value: impl Into<String>, href: impl Into<String>) -> Self
pub fn link(value: impl Into<String>, href: impl Into<String>) -> Self
Create a link text node.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Text
impl<'de> Deserialize<'de> for Text
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.