pub struct Source {
pub content: String,
pub bytes: Option<Vec<u8>>,
pub format: String,
pub path: Option<String>,
}Fields§
§content: String§bytes: Option<Vec<u8>>§format: String§path: Option<String>Implementations§
Source§impl Source
impl Source
pub fn from_text(text: impl Into<String>) -> Self
Sourcepub fn from_bytes(bytes: Vec<u8>, format: impl Into<String>) -> Self
pub fn from_bytes(bytes: Vec<u8>, format: impl Into<String>) -> Self
Build a source from in-memory bytes without touching the filesystem.
Binary formats keep their raw bytes and expose a lossy UTF-8 view as
content; this is the entry point used by the wasm bindings, where no
path-based loader is available.
Sourcepub fn from_bytes_for_format(
bytes: &[u8],
name: &str,
format: InputFormat,
) -> Result<Self>
pub fn from_bytes_for_format( bytes: &[u8], name: &str, format: InputFormat, ) -> Result<Self>
Build a source from in-memory bytes, mirroring how the path-based
loaders decode each format. name is the original file name (used for
gzip and markdown/latex detection) but is never read from disk.
pub fn from_path( path: impl AsRef<Path>, format: impl Into<String>, ) -> Result<Self>
pub fn from_text_or_gzip_path( path: impl AsRef<Path>, format: impl Into<String>, ) -> Result<Self>
pub fn from_pdf_path(path: impl AsRef<Path>) -> Result<Self>
pub fn from_binary_path( path: impl AsRef<Path>, format: impl Into<String>, ) -> Result<Self>
Trait Implementations§
impl Eq for Source
impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnsafeUnpin for Source
impl UnwindSafe for Source
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<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>
Converts
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>
Converts
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