[−][src]Struct mail_template::CwdBaseDir
Methods
impl CwdBaseDir
[src]
pub fn new_unchanged(path: PathBuf) -> Self
[src]
Creates a new CwdBaseDir
instance containing exactly the given path.
pub fn from_path<P>(path: P) -> Result<Self, Error> where
P: AsRef<Path> + Into<PathBuf>,
[src]
P: AsRef<Path> + Into<PathBuf>,
Creates a CwdBaseDir
from a path by prefixing the path with the
current working dir if it's relative.
If the path is not relative it's directly used.
Os state side effects
As this function accesses the current working directory (CWD) it's
not pure as the CWD can be changed (e.g. by std::env::set_current_dir
).
Error
As getting the CWD can fail this function can fail with a I/O Error, too.
pub fn to_base_path(&self) -> Result<&Path, Error>
[src]
Turns this path into a PathBuf
by stripping the current working dir
if it starts with it.
If this path does not start with the CWD it's returned directly.
Os state side effects
As this function used the current working dir (CWD) it is affected by any function changing the CWD as a side effect.
Error
Accessing the current working dir can fail, as such this function can fail.
pub fn into_inner_with_prefix(self) -> PathBuf
[src]
Turns this instance into the PathBuf
it dereferences to.
Methods from Deref<Target = PathBuf>
pub fn as_path(&self) -> &Path
1.0.0[src]
Coerces to a Path
slice.
Examples
use std::path::{Path, PathBuf}; let p = PathBuf::from("/test"); assert_eq!(Path::new("/test"), p.as_path());
pub fn push<P>(&mut self, path: P) where
P: AsRef<Path>,
1.0.0[src]
P: AsRef<Path>,
Extends self
with path
.
If path
is absolute, it replaces the current path.
On Windows:
- if
path
has a root but no prefix (e.g.,\windows
), it replaces everything except for the prefix (if any) ofself
. - if
path
has a prefix but no root, it replacesself
.
Examples
Pushing a relative path extends the existing path:
use std::path::PathBuf; let mut path = PathBuf::from("/tmp"); path.push("file.bk"); assert_eq!(path, PathBuf::from("/tmp/file.bk"));
Pushing an absolute path replaces the existing path:
use std::path::PathBuf; let mut path = PathBuf::from("/tmp"); path.push("/etc"); assert_eq!(path, PathBuf::from("/etc"));
pub fn pop(&mut self) -> bool
1.0.0[src]
Truncates self
to self.parent
.
Returns false
and does nothing if self.parent
is None
.
Otherwise, returns true
.
Examples
use std::path::{Path, PathBuf}; let mut p = PathBuf::from("/test/test.rs"); p.pop(); assert_eq!(Path::new("/test"), p); p.pop(); assert_eq!(Path::new("/"), p);
pub fn set_file_name<S>(&mut self, file_name: S) where
S: AsRef<OsStr>,
1.0.0[src]
S: AsRef<OsStr>,
Updates self.file_name
to file_name
.
If self.file_name
was None
, this is equivalent to pushing
file_name
.
Otherwise it is equivalent to calling pop
and then pushing
file_name
. The new path will be a sibling of the original path.
(That is, it will have the same parent.)
Examples
use std::path::PathBuf; let mut buf = PathBuf::from("/"); assert!(buf.file_name() == None); buf.set_file_name("bar"); assert!(buf == PathBuf::from("/bar")); assert!(buf.file_name().is_some()); buf.set_file_name("baz.txt"); assert!(buf == PathBuf::from("/baz.txt"));
pub fn set_extension<S>(&mut self, extension: S) -> bool where
S: AsRef<OsStr>,
1.0.0[src]
S: AsRef<OsStr>,
Updates self.extension
to extension
.
Returns false
and does nothing if self.file_name
is None
,
returns true
and updates the extension otherwise.
If self.extension
is None
, the extension is added; otherwise
it is replaced.
Examples
use std::path::{Path, PathBuf}; let mut p = PathBuf::from("/feel/the"); p.set_extension("force"); assert_eq!(Path::new("/feel/the.force"), p.as_path()); p.set_extension("dark_side"); assert_eq!(Path::new("/feel/the.dark_side"), p.as_path());
pub fn capacity(&self) -> usize
[src]
path_buf_capacity
)pub fn clear(&mut self)
[src]
path_buf_capacity
)pub fn reserve(&mut self, additional: usize)
[src]
path_buf_capacity
)pub fn reserve_exact(&mut self, additional: usize)
[src]
path_buf_capacity
)Invokes reserve_exact
on the underlying instance of OsString
.
pub fn shrink_to_fit(&mut self)
[src]
path_buf_capacity
)Invokes shrink_to_fit
on the underlying instance of OsString
.
pub fn shrink_to(&mut self, min_capacity: usize)
[src]
path_buf_capacity
)Trait Implementations
impl PartialOrd<CwdBaseDir> for CwdBaseDir
[src]
fn partial_cmp(&self, other: &CwdBaseDir) -> Option<Ordering>
[src]
fn lt(&self, other: &CwdBaseDir) -> bool
[src]
fn le(&self, other: &CwdBaseDir) -> bool
[src]
fn gt(&self, other: &CwdBaseDir) -> bool
[src]
fn ge(&self, other: &CwdBaseDir) -> bool
[src]
impl AsRef<Path> for CwdBaseDir
[src]
impl PartialEq<CwdBaseDir> for CwdBaseDir
[src]
fn eq(&self, other: &CwdBaseDir) -> bool
[src]
fn ne(&self, other: &CwdBaseDir) -> bool
[src]
impl Clone for CwdBaseDir
[src]
fn clone(&self) -> CwdBaseDir
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Ord for CwdBaseDir
[src]
fn cmp(&self, other: &CwdBaseDir) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more
impl Eq for CwdBaseDir
[src]
impl Debug for CwdBaseDir
[src]
impl Deref for CwdBaseDir
[src]
impl DerefMut for CwdBaseDir
[src]
impl Hash for CwdBaseDir
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Serialize for CwdBaseDir
[src]
impl<'de> Deserialize<'de> for CwdBaseDir
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl Send for CwdBaseDir
impl Sync for CwdBaseDir
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> HeaderTryFrom for T
[src]
fn try_from(val: T) -> Result<T, ComponentCreationError>
[src]
impl<F, T> HeaderTryInto for F where
T: HeaderTryFrom<F>,
[src]
T: HeaderTryFrom<F>,