pub enum MarkdownSource {
String(String),
File {
path: PathBuf,
content: String,
},
}Expand description
Represents the source of markdown content.
This enum provides a unified interface for working with markdown content that can come from either a static string or a file on disk.
Variants§
String(String)
Static string content (no auto-reload support).
File
File-based content with auto-reload support.
Implementations§
Source§impl MarkdownSource
impl MarkdownSource
Source§impl MarkdownSource
Constructor for creating a MarkdownSource from a string.
impl MarkdownSource
Constructor for creating a MarkdownSource from a string.
Sourcepub fn from_string(s: impl Into<String>) -> MarkdownSource
Available on crate feature markdown-preview only.
pub fn from_string(s: impl Into<String>) -> MarkdownSource
markdown-preview only.Source§impl MarkdownSource
Method to get the content of a MarkdownSource.
impl MarkdownSource
Method to get the content of a MarkdownSource.
Source§impl MarkdownSource
Method to check if a MarkdownSource is file-based.
impl MarkdownSource
Method to check if a MarkdownSource is file-based.
Source§impl MarkdownSource
Method to check if a MarkdownSource is string-based.
impl MarkdownSource
Method to check if a MarkdownSource is string-based.
Source§impl MarkdownSource
Method to get the file path of a MarkdownSource.
impl MarkdownSource
Method to get the file path of a MarkdownSource.
Source§impl MarkdownSource
Method to reload content from a file.
impl MarkdownSource
Method to reload content from a file.
Sourcepub fn reload(&mut self) -> Result<bool, Error>
Available on crate feature markdown-preview only.
pub fn reload(&mut self) -> Result<bool, Error>
markdown-preview only.Reload the content from the file.
For string sources, this is a no-op and returns Ok(false).
For file sources, this re-reads the file and returns Ok(true) if
the content has changed.
§Errors
Returns an io::Error if the file cannot be read.
Source§impl MarkdownSource
Method to set content directly on a MarkdownSource.
impl MarkdownSource
Method to set content directly on a MarkdownSource.
Sourcepub fn set_content(&mut self, new_content: impl Into<String>) -> bool
Available on crate feature markdown-preview only.
pub fn set_content(&mut self, new_content: impl Into<String>) -> bool
markdown-preview only.Set the content directly (for string sources).
This is useful for updating string-based sources programmatically. For file sources, this updates the cached content but does not write to disk.
Returns true if the content was changed.
Trait Implementations§
Source§impl Clone for MarkdownSource
impl Clone for MarkdownSource
Source§fn clone(&self) -> MarkdownSource
fn clone(&self) -> MarkdownSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MarkdownSource
impl Debug for MarkdownSource
Source§impl Default for MarkdownSource
Default trait implementation for MarkdownSource.
impl Default for MarkdownSource
Default trait implementation for MarkdownSource.
Source§fn default() -> MarkdownSource
fn default() -> MarkdownSource
Source§impl From<&str> for MarkdownSource
From<&str> trait implementation for MarkdownSource.
impl From<&str> for MarkdownSource
From<&str> trait implementation for MarkdownSource.
Source§fn from(s: &str) -> MarkdownSource
fn from(s: &str) -> MarkdownSource
Source§impl From<String> for MarkdownSource
From trait implementation for MarkdownSource.
impl From<String> for MarkdownSource
FromMarkdownSource.
Source§fn from(s: String) -> MarkdownSource
fn from(s: String) -> MarkdownSource
Auto Trait Implementations§
impl Freeze for MarkdownSource
impl RefUnwindSafe for MarkdownSource
impl Send for MarkdownSource
impl Sync for MarkdownSource
impl Unpin for MarkdownSource
impl UnsafeUnpin for MarkdownSource
impl UnwindSafe for MarkdownSource
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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