Skip to main content

AnchoredPath

Struct AnchoredPath 

Source
pub struct AnchoredPath { /* private fields */ }
Expand description

A path as given, and the path to hand to Win32 for it.

The two are the same unless the path was grafted, by the rules in this module’s documentation. It is what OpenFile and WatchDirectory hold, and is public for a crate that builds a request of its own and performs it later on another thread, so that it fixes the meaning of a relative path by the same contract and does not keep a second one (D-30).

§Example

use windows_namespace_request_sys::AnchoredPath;
use wtf_string::Wtf16String;

// An absolute path is handed to Win32 as it was given.
let absolute = AnchoredPath::new(Wtf16String::from(r"C:\Windows"))?;
assert_eq!(absolute.given(), absolute.win32());

// A relative name is grafted onto the current directory as it is now.
let relative = AnchoredPath::new(Wtf16String::from("a-child"))?;
assert_eq!(relative.given().to_string_lossy(), "a-child");
let expected = std::env::current_dir()?.join("a-child");
assert_eq!(relative.win32().to_string_lossy(), expected.to_string_lossy());

Implementations§

Source§

impl AnchoredPath

Source

pub fn new(given: Wtf16String) -> Result<Self, PathCaptureError>

Anchors given to the process current directory as it is now.

§Errors

PathCaptureError::InteriorNul for a path with a NUL before its end, and otherwise the failure of GetCurrentDirectoryW, which is called only for a path whose shape permits a graft.

Source

pub fn given(&self) -> &Wtf16Str

The path exactly as the caller gave it.

Source

pub fn win32(&self) -> &Wtf16Str

The path that is handed to Win32.

Trait Implementations§

Source§

impl Clone for AnchoredPath

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AnchoredPath

Source§

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

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

impl Eq for AnchoredPath

Source§

impl Hash for AnchoredPath

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AnchoredPath

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AnchoredPath

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.