Struct PasswordMasked

struct PasswordMasked<'a, T: ?Sized> { ... }

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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())

Implementations

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

fn replace_password<D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())
fn replace_password_with<F, D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())

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

fn replace_password<D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())
fn replace_password_with<F, D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())

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

fn replace_password<D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())
fn replace_password_with<F, D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())

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

fn replace_password<D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())
fn replace_password_with<F, D>(self: &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::validate::Error;
# #[cfg(feature = "alloc")] {
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"
);
# }
# Ok::<_, Error>(())

impl<'a, T> Freeze for PasswordMasked<'a, T>

impl<'a, T> RefUnwindSafe for PasswordMasked<'a, T>

impl<'a, T> Send for PasswordMasked<'a, T>

impl<'a, T> Sync for PasswordMasked<'a, T>

impl<'a, T> Unpin for PasswordMasked<'a, T>

impl<'a, T> UnsafeUnpin for PasswordMasked<'a, T>

impl<'a, T> UnwindSafe for PasswordMasked<'a, T>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<T> Any for PasswordMasked<'a, T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PasswordMasked<'a, T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for PasswordMasked<'a, T>

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

impl<T> CloneToUninit for PasswordMasked<'a, T>

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

impl<T> From for PasswordMasked<'a, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for PasswordMasked<'a, T>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for PasswordMasked<'a, T>

fn to_string(self: &Self) -> String

impl<T> ToStringFallible for PasswordMasked<'a, T>

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

[ToString::to_string]alloc::string::ToString::to_string, but without panic on OOM.

impl<T, U> Into for PasswordMasked<'a, T>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for PasswordMasked<'a, T>

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

impl<T, U> TryInto for PasswordMasked<'a, T>

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