[][src]Struct tp_note::content::Content

pub struct Content {
    s: String,

This is a newtype and thin wrapper around the note's content. It deals with operating system specific handling of newlines.


s: String


impl Content[src]

The content of a note is stored in some Rust-like utf-8 string with one \n character as newline. If present, a Byte Order Mark BOM is removed while reading with new().

pub fn new(input: &str) -> Self[src]

Reads also notes created on Windows machines: in this case it converts all /// \r\n to \n.

pub fn to_osstring(&self) -> String[src]

Write out the content string to be saved on disk. The format varies depending on the operating system: On Unix a newline is represented by one single byte: \n. On Windows a newline consists of two bytes: \r\n.

Methods from Deref<Target = String>

pub fn as_str(&self) -> &str1.7.0[src]

Extracts a string slice containing the entire String.


Basic usage:

let s = String::from("foo");

assert_eq!("foo", s.as_str());

pub fn capacity(&self) -> usize1.0.0[src]

Returns this String's capacity, in bytes.


Basic usage:

let s = String::with_capacity(10);

assert!(s.capacity() >= 10);

pub fn as_bytes(&self) -> &[u8]1.0.0[src]

Returns a byte slice of this String's contents.

The inverse of this method is from_utf8.


Basic usage:

let s = String::from("hello");

assert_eq!(&[104, 101, 108, 108, 111], s.as_bytes());

pub fn len(&self) -> usize1.0.0[src]

Returns the length of this String, in bytes, not [char]s or graphemes. In other words, it may not be what a human considers the length of the string.


Basic usage:

let a = String::from("foo");
assert_eq!(a.len(), 3);

let fancy_f = String::from("ƒoo");
assert_eq!(fancy_f.len(), 4);
assert_eq!(fancy_f.chars().count(), 3);

pub fn is_empty(&self) -> bool1.0.0[src]

Returns true if this String has a length of zero, and false otherwise.


Basic usage:

let mut v = String::new();


Trait Implementations

impl Debug for Content[src]

impl Deref for Content[src]

Automatically dereference the newtype's inner string.

type Target = String

The resulting type after dereferencing.

impl PartialEq<Content> for Content[src]

impl StructuralPartialEq for Content[src]

Auto Trait Implementations

impl RefUnwindSafe for Content

impl Send for Content

impl Sync for Content

impl Unpin for Content

impl UnwindSafe for Content

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> Sealed<T> for T where
    T: ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,