Struct SrcDstConfig

Source
pub struct SrcDstConfig {
    pub allow_from_stdin: bool,
    pub allow_to_stdout: bool,
    pub auto_tnamed_dst_file: bool,
    pub auto_tnamed_dst_dir: bool,
    pub default_extension: OsString,
    pub allow_inplace: bool,
}
Expand description

Use single hyphen (-) as path to indicate IO from Stdio.

§Notes

  • Auto time-based unique naming (auto_tnamed_dst_) only takes effect when DST is not provided.

Fields§

§allow_from_stdin: bool§allow_to_stdout: bool§auto_tnamed_dst_file: bool§auto_tnamed_dst_dir: bool§default_extension: OsString§allow_inplace: bool

Disallowed by default. There may be a potential to open and create the same file at the same time.

Implementations§

Source§

impl SrcDstConfig

Source

pub fn new<S: AsRef<OsStr>>(default_extension: S) -> Self

Source

pub fn new_with_allow_inplace<S: AsRef<OsStr>>(default_extension: S) -> Self

Source

pub fn parse<P: AsRef<Path>>( &self, src: P, dst: Option<P>, ) -> Result<Result<SrcDstPairs, SrcDstError>>

§Possible Combinations
SRC => DST:   Stdout,6   File   Dir     NotProvided
Stdin,6          1+2      1      1         1+3,5
File               2      ✓      ✓           3
Dir                ×      ×      ✓           4
  1. allow_from_stdin.
  2. allow_to_stdout.
  3. auto_tnamed_dst_file.
  4. auto_tnamed_dst_dir. Note: A directory with specified name will not be created automatically (an error will be returned if it does not exist).
  5. Note that std::env::current_dir will be used as output directory.
  6. Stdio will be always treated as a file.

Trait Implementations§

Source§

impl Clone for SrcDstConfig

Source§

fn clone(&self) -> SrcDstConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SrcDstConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SrcDstConfig

Source§

fn eq(&self, other: &SrcDstConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for SrcDstConfig

Source§

impl StructuralPartialEq for SrcDstConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.