pub struct TextDocument<'a> {
pub id: &'a str,
pub text: &'a str,
pub language: Option<&'a str>,
pub timestamp: Option<Timestamp>,
}Expand description
Borrowed text document used as the lightweight boundary between text crates.
Fields§
§id: &'a strStable caller-supplied document id.
text: &'a strUTF-8 document body.
language: Option<&'a str>Optional BCP-47-style language hint such as en.
timestamp: Option<Timestamp>Optional media timestamp when this document came from a timed segment.
Implementations§
Source§impl<'a> TextDocument<'a>
impl<'a> TextDocument<'a>
Sourcepub fn from_segment_id(id: &'a str, segment: &TextSegment<'a>) -> Self
pub fn from_segment_id(id: &'a str, segment: &TextSegment<'a>) -> Self
Builds this value from segment identifier.
Sourcepub fn from_stream_segment(
stream_id: &str,
segment: &TextSegment<'_>,
) -> OwnedTextDocument
pub fn from_stream_segment( stream_id: &str, segment: &TextSegment<'_>, ) -> OwnedTextDocument
Builds this value from stream segment.
Sourcepub fn from_segment(stream_id: &'a str, segment: &TextSegment<'a>) -> Self
pub fn from_segment(stream_id: &'a str, segment: &TextSegment<'a>) -> Self
Builds a document using stream_id directly as the document id.
Prefer TextDocument::from_segment_id when the id has already been
chosen, or TextDocument::from_stream_segment when converting a
stream segment into the canonical stream_id:segment_index id.
Trait Implementations§
Source§impl<'a> Clone for TextDocument<'a>
impl<'a> Clone for TextDocument<'a>
Source§fn clone(&self) -> TextDocument<'a>
fn clone(&self) -> TextDocument<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for TextDocument<'a>
Source§impl<'a> Debug for TextDocument<'a>
impl<'a> Debug for TextDocument<'a>
impl<'a> Eq for TextDocument<'a>
Source§impl From<TextDocument<'_>> for TextDocumentContract
impl From<TextDocument<'_>> for TextDocumentContract
Source§fn from(value: TextDocument<'_>) -> Self
fn from(value: TextDocument<'_>) -> Self
Converts to this type from the input type.
Source§impl IntoTextDocumentContract for TextDocument<'_>
impl IntoTextDocumentContract for TextDocument<'_>
Source§impl<'a> PartialEq for TextDocument<'a>
impl<'a> PartialEq for TextDocument<'a>
Source§fn eq(&self, other: &TextDocument<'a>) -> bool
fn eq(&self, other: &TextDocument<'a>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<'a> StructuralPartialEq for TextDocument<'a>
Auto Trait Implementations§
impl<'a> Freeze for TextDocument<'a>
impl<'a> RefUnwindSafe for TextDocument<'a>
impl<'a> Send for TextDocument<'a>
impl<'a> Sync for TextDocument<'a>
impl<'a> Unpin for TextDocument<'a>
impl<'a> UnsafeUnpin for TextDocument<'a>
impl<'a> UnwindSafe for TextDocument<'a>
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