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

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"
);

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"
);

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"
);

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"
);

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"
);

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"
);

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"
);

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Available on crate feature alloc only.

Conversion target type.

Available on crate feature alloc only.

Converts the value to the allocated string.

Available on crate feature alloc only.

Converts the value to the allocated string. Read more

Available on crate feature alloc only.

Conversion target type.

Available on crate feature alloc only.

Converts the value to the allocated string.

Available on crate feature alloc only.

Converts the value to the allocated string. Read more

Available on crate feature alloc only.

Conversion target type.

Available on crate feature alloc only.

Converts the value to the allocated string.

Available on crate feature alloc only.

Converts the value to the allocated string. Read more

Available on crate feature alloc only.

Conversion target type.

Available on crate feature alloc only.

Converts the value to the allocated string.

Available on crate feature alloc only.

Converts the value to the allocated string. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

Converts the given value to a String. Read more

Available on crate feature alloc only.

ToString::to_string, but without panic on OOM.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.