Struct iri_string::mask_password::PasswordMasked

source ·
pub struct PasswordMasked<'a, T: ?Sized> { /* private fields */ }
Expand description

A wrapper of an IRI string that masks the non-empty password when Displayed.

This is a retrun type of mask_password method of IRI string types (such as RiStr::mask_password).

§Examples

use iri_string::types::UriReferenceStr;

let iri = UriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();
assert_eq!(masked.to_string(), "http://user:@example.com/path?query");

assert_eq!(
    masked.replace_password("${password}").to_string(),
    "http://user:${password}@example.com/path?query"
);

Implementations§

source§

impl<'a, S: Spec> PasswordMasked<'a, RiReferenceStr<S>>

source

pub fn replace_password<D>( &self, alt: D ) -> PasswordReplaced<'a, RiReferenceStr<S>, D>
where D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

assert_eq!(
    masked.replace_password("${password}").to_string(),
    "http://user:${password}@example.com/path?query"
);
source

pub fn replace_password_with<F, D>( &self, replace: F ) -> PasswordReplaced<'a, RiReferenceStr<S>, D>
where F: FnOnce(&str) -> D, D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

let replaced = masked
    .replace_password_with(|password| format!("{{{} chars}}", password.len()));
assert_eq!(
    replaced.to_string(),
    "http://user:{8 chars}@example.com/path?query"
);
source§

impl<'a, S: Spec> PasswordMasked<'a, RiStr<S>>

source

pub fn replace_password<D>(&self, alt: D) -> PasswordReplaced<'a, RiStr<S>, D>
where D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

assert_eq!(
    masked.replace_password("${password}").to_string(),
    "http://user:${password}@example.com/path?query"
);
source

pub fn replace_password_with<F, D>( &self, replace: F ) -> PasswordReplaced<'a, RiStr<S>, D>
where F: FnOnce(&str) -> D, D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

let replaced = masked
    .replace_password_with(|password| format!("{{{} chars}}", password.len()));
assert_eq!(
    replaced.to_string(),
    "http://user:{8 chars}@example.com/path?query"
);
source§

impl<'a, S: Spec> PasswordMasked<'a, RiAbsoluteStr<S>>

source

pub fn replace_password<D>( &self, alt: D ) -> PasswordReplaced<'a, RiAbsoluteStr<S>, D>
where D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

assert_eq!(
    masked.replace_password("${password}").to_string(),
    "http://user:${password}@example.com/path?query"
);
source

pub fn replace_password_with<F, D>( &self, replace: F ) -> PasswordReplaced<'a, RiAbsoluteStr<S>, D>
where F: FnOnce(&str) -> D, D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

let replaced = masked
    .replace_password_with(|password| format!("{{{} chars}}", password.len()));
assert_eq!(
    replaced.to_string(),
    "http://user:{8 chars}@example.com/path?query"
);
source§

impl<'a, S: Spec> PasswordMasked<'a, RiRelativeStr<S>>

source

pub fn replace_password<D>( &self, alt: D ) -> PasswordReplaced<'a, RiRelativeStr<S>, D>
where D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

assert_eq!(
    masked.replace_password("${password}").to_string(),
    "http://user:${password}@example.com/path?query"
);
source

pub fn replace_password_with<F, D>( &self, replace: F ) -> PasswordReplaced<'a, RiRelativeStr<S>, D>
where F: FnOnce(&str) -> D, D: Display,

Replaces the password with the given arbitrary content.

Note that the result might be invalid as an IRI since arbitrary string can go to the place of the password.

§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriReferenceStr;

let iri = IriReferenceStr::new("http://user:password@example.com/path?query")?;
let masked = iri.mask_password();

let replaced = masked
    .replace_password_with(|password| format!("{{{} chars}}", password.len()));
assert_eq!(
    replaced.to_string(),
    "http://user:{8 chars}@example.com/path?query"
);

Trait Implementations§

source§

impl<'a, T: Clone + ?Sized> Clone for PasswordMasked<'a, T>

source§

fn clone(&self) -> PasswordMasked<'a, T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<S: Spec> Debug for PasswordMasked<'_, RiAbsoluteStr<S>>

source§

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

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

impl<S: Spec> Debug for PasswordMasked<'_, RiReferenceStr<S>>

source§

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

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

impl<S: Spec> Debug for PasswordMasked<'_, RiRelativeStr<S>>

source§

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

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

impl<S: Spec> Debug for PasswordMasked<'_, RiStr<S>>

source§

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

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

impl<S: Spec> Display for PasswordMasked<'_, RiAbsoluteStr<S>>

source§

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

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

impl<S: Spec> Display for PasswordMasked<'_, RiReferenceStr<S>>

source§

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

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

impl<S: Spec> Display for PasswordMasked<'_, RiRelativeStr<S>>

source§

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

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

impl<S: Spec> Display for PasswordMasked<'_, RiStr<S>>

source§

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

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

impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiAbsoluteStr<S>>

§

type Target = RiAbsoluteString<S>

Available on crate feature alloc only.
Conversion target type.
source§

fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>

Available on crate feature alloc only.
Converts the value to the allocated string.
source§

fn to_dedicated_string(&self) -> Self::Target

Available on crate feature alloc only.
Converts the value to the allocated string. Read more
source§

impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiReferenceStr<S>>

§

type Target = RiReferenceString<S>

Available on crate feature alloc only.
Conversion target type.
source§

fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>

Available on crate feature alloc only.
Converts the value to the allocated string.
source§

fn to_dedicated_string(&self) -> Self::Target

Available on crate feature alloc only.
Converts the value to the allocated string. Read more
source§

impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiRelativeStr<S>>

§

type Target = RiRelativeString<S>

Available on crate feature alloc only.
Conversion target type.
source§

fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>

Available on crate feature alloc only.
Converts the value to the allocated string.
source§

fn to_dedicated_string(&self) -> Self::Target

Available on crate feature alloc only.
Converts the value to the allocated string. Read more
source§

impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiStr<S>>

§

type Target = RiString<S>

Available on crate feature alloc only.
Conversion target type.
source§

fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>

Available on crate feature alloc only.
Converts the value to the allocated string.
source§

fn to_dedicated_string(&self) -> Self::Target

Available on crate feature alloc only.
Converts the value to the allocated string. Read more
source§

impl<'a, T: Copy + ?Sized> Copy for PasswordMasked<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for PasswordMasked<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for PasswordMasked<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for PasswordMasked<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Sync for PasswordMasked<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for PasswordMasked<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for PasswordMasked<'a, T>
where T: RefUnwindSafe + ?Sized,

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> 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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> ToStringFallible for T
where T: Display,

source§

fn try_to_string(&self) -> Result<String, TryReserveError>

Available on crate feature alloc only.

ToString::to_string, but without panic on OOM.

source§

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

§

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>,

§

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.