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 Display
ed.
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
sourceimpl<'a, S: Spec> PasswordMasked<'a, RiReferenceStr<S>>
impl<'a, S: Spec> PasswordMasked<'a, RiReferenceStr<S>>
sourcepub fn replace_password<D>(
&self,
alt: D
) -> PasswordReplaced<'a, RiReferenceStr<S>, D>where
D: Display,
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"
);
sourcepub fn replace_password_with<F, D>(
&self,
replace: F
) -> PasswordReplaced<'a, RiReferenceStr<S>, D>where
F: FnOnce(&str) -> D,
D: Display,
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"
);
sourceimpl<'a, S: Spec> PasswordMasked<'a, RiStr<S>>
impl<'a, S: Spec> PasswordMasked<'a, RiStr<S>>
sourcepub fn replace_password<D>(&self, alt: D) -> PasswordReplaced<'a, RiStr<S>, D>where
D: Display,
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"
);
sourcepub fn replace_password_with<F, D>(
&self,
replace: F
) -> PasswordReplaced<'a, RiStr<S>, D>where
F: FnOnce(&str) -> D,
D: Display,
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"
);
sourceimpl<'a, S: Spec> PasswordMasked<'a, RiAbsoluteStr<S>>
impl<'a, S: Spec> PasswordMasked<'a, RiAbsoluteStr<S>>
sourcepub fn replace_password<D>(
&self,
alt: D
) -> PasswordReplaced<'a, RiAbsoluteStr<S>, D>where
D: Display,
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"
);
sourcepub fn replace_password_with<F, D>(
&self,
replace: F
) -> PasswordReplaced<'a, RiAbsoluteStr<S>, D>where
F: FnOnce(&str) -> D,
D: Display,
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"
);
sourceimpl<'a, S: Spec> PasswordMasked<'a, RiRelativeStr<S>>
impl<'a, S: Spec> PasswordMasked<'a, RiRelativeStr<S>>
sourcepub fn replace_password<D>(
&self,
alt: D
) -> PasswordReplaced<'a, RiRelativeStr<S>, D>where
D: Display,
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"
);
sourcepub fn replace_password_with<F, D>(
&self,
replace: F
) -> PasswordReplaced<'a, RiRelativeStr<S>, D>where
F: FnOnce(&str) -> D,
D: Display,
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
sourceimpl<'a, T: Clone + ?Sized> Clone for PasswordMasked<'a, T>
impl<'a, T: Clone + ?Sized> Clone for PasswordMasked<'a, T>
sourcefn clone(&self) -> PasswordMasked<'a, T>
fn clone(&self) -> PasswordMasked<'a, T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<S: Spec> Debug for PasswordMasked<'_, RiAbsoluteStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiAbsoluteStr<S>>
sourceimpl<S: Spec> Debug for PasswordMasked<'_, RiReferenceStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiReferenceStr<S>>
sourceimpl<S: Spec> Debug for PasswordMasked<'_, RiRelativeStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiRelativeStr<S>>
sourceimpl<S: Spec> Debug for PasswordMasked<'_, RiStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiStr<S>>
sourceimpl<S: Spec> Display for PasswordMasked<'_, RiAbsoluteStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiAbsoluteStr<S>>
sourceimpl<S: Spec> Display for PasswordMasked<'_, RiReferenceStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiReferenceStr<S>>
sourceimpl<S: Spec> Display for PasswordMasked<'_, RiRelativeStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiRelativeStr<S>>
sourceimpl<S: Spec> Display for PasswordMasked<'_, RiStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiStr<S>>
sourceimpl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiAbsoluteStr<S>>
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiAbsoluteStr<S>>
sourcefn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
alloc
only.Converts the value to the allocated string.
sourcefn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
alloc
only.Converts the value to the allocated string. Read more
sourceimpl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiReferenceStr<S>>
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiReferenceStr<S>>
sourcefn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
alloc
only.Converts the value to the allocated string.
sourcefn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
alloc
only.Converts the value to the allocated string. Read more
sourceimpl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiRelativeStr<S>>
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiRelativeStr<S>>
sourcefn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
alloc
only.Converts the value to the allocated string.
sourcefn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
alloc
only.Converts the value to the allocated string. Read more
sourceimpl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiStr<S>>
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiStr<S>>
sourcefn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
alloc
only.Converts the value to the allocated string.
sourcefn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
alloc
only.Converts the value to the allocated string. Read more
impl<'a, T: Copy + ?Sized> Copy for PasswordMasked<'a, T>
Auto Trait Implementations
impl<'a, T: ?Sized> RefUnwindSafe for PasswordMasked<'a, T>where
T: RefUnwindSafe,
impl<'a, T: ?Sized> Send for PasswordMasked<'a, T>where
T: Sync,
impl<'a, T: ?Sized> Sync for PasswordMasked<'a, T>where
T: Sync,
impl<'a, T: ?Sized> Unpin for PasswordMasked<'a, T>
impl<'a, T: ?Sized> UnwindSafe for PasswordMasked<'a, T>where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
sourcefn try_to_string(&self) -> Result<String, TryReserveError>
Available on crate feature alloc
only.
fn try_to_string(&self) -> Result<String, TryReserveError>
alloc
only.ToString::to_string
, but without panic on OOM.