Struct tpnote_lib::content::ContentString
source · #[repr(transparent)]pub struct ContentString { /* private fields */ }Expand description
Holds the notes content in a string and two string slices
header and body.
This struct is self referencial.
It deals with operating system specific handling of newlines.
The content of a note is stored as UTF-8 string with
one \n character as newline. If present, a Byte Order Mark
BOM is removed while reading with new().
Implementations
sourceimpl ContentString
impl ContentString
pub fn new(
owner: String,
dependent_builder: impl for<'_q> FnOnce(&'_q String) -> ContentRef<'_q>
) -> Self
pub fn try_new<Err>(
owner: String,
dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Result<ContentRef<'_q>, Err>
) -> Result<Self, Err>
pub fn try_new_or_recover<Err>(
owner: String,
dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Result<ContentRef<'_q>, Err>
) -> Result<Self, (String, Err)>
pub fn borrow_owner<'_q>(&'_q self) -> &'_q String
pub fn with_dependent<'outer_fn, Ret>(
&'outer_fn self,
func: impl for<'_q> FnOnce(&'_q String, &'outer_fn ContentRef<'_q>) -> Ret
) -> Ret
pub fn with_dependent_mut<'outer_fn, Ret>(
&'outer_fn mut self,
func: impl for<'_q> FnOnce(&'_q String, &'outer_fn mut ContentRef<'_q>) -> Ret
) -> Ret
pub fn borrow_dependent<'_q>(&'_q self) -> &'_q ContentRef<'_q>
pub fn into_owner(self) -> String
Trait Implementations
sourceimpl AsRef<str> for ContentString
impl AsRef<str> for ContentString
Returns the whole raw content with header and body.
Possible \r\n in the input are replaced by \n.
sourceimpl Content for ContentString
impl Content for ContentString
sourcefn from_string(input: String) -> Self
fn from_string(input: String) -> Self
Self referential. The constructor splits the content in header and body.
sourcefn open(path: &Path) -> Result<Self, Error>where
Self: Sized,
fn open(path: &Path) -> Result<Self, Error>where
Self: Sized,
Reads the file at
path and stores the content
Content. Possible \r\n are replaced by \n.
This trait has a default implementation, the empty content. Read moresourcefn from_string_with_cr(input: String) -> Self
fn from_string_with_cr(input: String) -> Self
Constructor that reads a structured document with a YAML header
and body. All
\r\n are converted to \n if there are any.
If not, no memory allocation occurs and the buffer remains untouched. Read moresourcefn save_as(&self, new_file_path: &Path) -> Result<(), Error>
fn save_as(&self, new_file_path: &Path) -> Result<(), Error>
Writes the note to disk with
new_file_path as filename.
If new_file_path contains missing directories, they will be
created on the fly. Read moresourceimpl Debug for ContentString
impl Debug for ContentString
sourceimpl Default for ContentString
impl Default for ContentString
sourceimpl Display for ContentString
impl Display for ContentString
Delegates the printing to Display for ContentRef.
sourceimpl Drop for ContentString
impl Drop for ContentString
sourceimpl PartialEq<ContentString> for ContentString
impl PartialEq<ContentString> for ContentString
impl Eq for ContentString
Auto Trait Implementations
impl RefUnwindSafe for ContentString
impl Send for ContentString
impl Sync for ContentString
impl Unpin for ContentString
impl UnwindSafe for ContentString
Blanket Implementations
impl<T> AsUncased for Twhere
T: AsRef<str> + ?Sized,
impl<T> AsUncased for Twhere
T: AsRef<str> + ?Sized,
fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
Convert
self to an [UncasedStr].sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.