pub struct DocumentFragment { /* private fields */ }Expand description
A piece of rich text that can be inserted into a TextDocument.
DocumentFragment is the clipboard/interchange type. It carries
blocks, inline elements, and formatting in a format-agnostic
internal representation.
Implementations§
Source§impl DocumentFragment
impl DocumentFragment
Sourcepub fn from_plain_text(text: &str) -> Self
pub fn from_plain_text(text: &str) -> Self
Create a fragment from plain text.
Builds valid fragment data so the fragment can be inserted via
TextCursor::insert_fragment.
Sourcepub fn from_markdown(markdown: &str) -> Self
pub fn from_markdown(markdown: &str) -> Self
Create a fragment from Markdown.
Sourcepub fn from_document(doc: &TextDocument) -> Result<Self>
pub fn from_document(doc: &TextDocument) -> Result<Self>
Create a fragment from an entire document.
Sourcepub fn to_plain_text(&self) -> &str
pub fn to_plain_text(&self) -> &str
Export the fragment as plain text.
Sourcepub fn to_markdown(&self) -> String
pub fn to_markdown(&self) -> String
Export the fragment as Markdown.
Trait Implementations§
Source§impl Clone for DocumentFragment
impl Clone for DocumentFragment
Source§fn clone(&self) -> DocumentFragment
fn clone(&self) -> DocumentFragment
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 Debug for DocumentFragment
impl Debug for DocumentFragment
Auto Trait Implementations§
impl Freeze for DocumentFragment
impl RefUnwindSafe for DocumentFragment
impl Send for DocumentFragment
impl Sync for DocumentFragment
impl Unpin for DocumentFragment
impl UnsafeUnpin for DocumentFragment
impl UnwindSafe for DocumentFragment
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