pub struct FilePath(/* private fields */);Expand description
A file’s path in a pack, dist/mermaid.js.
Implementations§
Source§impl FilePath
impl FilePath
Sourcepub fn new(text: impl Into<String>) -> Result<Self, Invalid>
pub fn new(text: impl Into<String>) -> Result<Self, Invalid>
The path text, when it is one: /-separated names, none of them empty, . or .., with no \ or : (a
Windows path of its own), so it can’t name a file outside the pack.
§Errors
Invalid::Path when it isn’t one.
Sourcepub fn join(&self, relative: &str) -> Option<Self>
pub fn join(&self, relative: &str) -> Option<Self>
The file relative (./card.comp.md, ../ui/x.jsx) names, seen from this file’s folder; None when it
leaves the pack, or names its folder.
Sourcepub fn join_folder(&self, relative: &str) -> Option<String>
pub fn join_folder(&self, relative: &str) -> Option<String>
The folder relative (./, ../guide/) names, seen from this file’s folder: its /-separated path, empty
for the root folder; None when it leaves the root, or one of its names isn’t a file’s name.
let post = FilePath::new("posts/harbour.comp.md").expect("a path");
assert_eq!(post.join_folder("../guide/").as_deref(), Some("guide"));
assert_eq!(post.join_folder("../").as_deref(), Some(""));
assert_eq!(post.join_folder("../../"), None);Trait Implementations§
Source§impl<'de> Deserialize<'de> for FilePath
impl<'de> Deserialize<'de> for FilePath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for FilePath
Source§impl Ord for FilePath
impl Ord for FilePath
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for FilePath
impl PartialOrd for FilePath
impl StructuralPartialEq for FilePath
Auto Trait Implementations§
impl Forget for FilePath
impl Freeze for FilePath
impl Move for FilePath
impl RefUnwindSafe for FilePath
impl Send for FilePathwhere
RawVecInner: Send,
impl Sync for FilePathwhere
RawVecInner: Sync,
impl Unpin for FilePath
impl UnsafeUnpin for FilePath
impl UnwindSafe for FilePathwhere
RawVecInner: UnwindSafe,
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