Trait tpnote_lib::filename::NotePath
source · pub trait NotePath {
// Required methods
fn disassemble(&self) -> (&str, &str, &str, &str, &str);
fn exclude_copy_counter_eq(&self, p2: &Path) -> bool;
fn has_wellformed_filename(&self) -> bool;
fn trim_copy_counter(tag: &str) -> &str;
fn has_tpnote_extension(&self) -> bool;
}Expand description
Extents Path with methods dealing with paths to Tp-Note files.
Required Methods§
sourcefn disassemble(&self) -> (&str, &str, &str, &str, &str)
fn disassemble(&self) -> (&str, &str, &str, &str, &str)
Helper function that decomposes a fully qualified path name
into (sort_tag, stem_copy_counter_ext, stem, copy_counter, ext).
sourcefn exclude_copy_counter_eq(&self, p2: &Path) -> bool
fn exclude_copy_counter_eq(&self, p2: &Path) -> bool
Compares with another Path to a Tp-Note file. They are considered equal
even when the copy counter is different.
sourcefn has_wellformed_filename(&self) -> bool
fn has_wellformed_filename(&self) -> bool
Check if a Path points to a file with a “wellformed” filename.
sourcefn trim_copy_counter(tag: &str) -> &str
fn trim_copy_counter(tag: &str) -> &str
Helper function: Removes the copy counter from the file stem.
sourcefn has_tpnote_extension(&self) -> bool
fn has_tpnote_extension(&self) -> bool
Compare to all file extensions Tp-Note can open.
Implementations on Foreign Types§
source§impl NotePath for Path
impl NotePath for Path
source§fn exclude_copy_counter_eq(&self, p2: &Path) -> bool
fn exclude_copy_counter_eq(&self, p2: &Path) -> bool
Check if 2 filenames are equal. Compare all parts, except the copy counter. Consider 2 file identical even when they have a different copy counter.
source§fn has_wellformed_filename(&self) -> bool
fn has_wellformed_filename(&self) -> bool
Check if a path points to a file with a
“well formed” filename.
We consider it well formed,
- if
pathhas no directory components, only a filename, and - if the filename is not empty, and
- if the filename is a dot file (len >1 and without whitespace), or
- if the filename has an extension. A valid extension must not contain whitespace.
use std::path::Path;
use tpnote_lib::filename::NotePath;
let f = Path::new("tpnote.toml");
assert!(f.has_wellformed_filename());
let f = Path::new("dir/tpnote.toml");
assert!(f.has_wellformed_filename());
let f = Path::new("tpnote.to ml");
assert!(!f.has_wellformed_filename());source§fn trim_copy_counter(tag: &str) -> &str
fn trim_copy_counter(tag: &str) -> &str
Helper function that trims the copy counter at the end of string. If there is none, return the same.
source§fn has_tpnote_extension(&self) -> bool
fn has_tpnote_extension(&self) -> bool
True if the filename extension is considered as a Tp-Note file. Checks if the filename extension is one of the following list taken from the configuration file: FILENAME_EXTENSIONS_MD, FILENAME_EXTENSIONS_RST, FILENAME_EXTENSIONS_HTML, FILENAME_EXTENSIONS_TXT, FILENAME_EXTENSIONS_NO_VIEWER