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§
source§impl<'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>
pub fn replace_password_with<F, D>( &self, replace: F, ) -> PasswordReplaced<'a, RiReferenceStr<S>, D>
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>>
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>
pub fn replace_password_with<F, D>( &self, replace: F, ) -> PasswordReplaced<'a, RiStr<S>, D>
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>>
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>
pub fn replace_password_with<F, D>( &self, replace: F, ) -> PasswordReplaced<'a, RiAbsoluteStr<S>, D>
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>>
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>
pub fn replace_password_with<F, D>( &self, replace: F, ) -> PasswordReplaced<'a, RiRelativeStr<S>, D>
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>
impl<'a, T: Clone + ?Sized> Clone for PasswordMasked<'a, T>
source§fn clone(&self) -> PasswordMasked<'a, T>
fn clone(&self) -> PasswordMasked<'a, T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: Spec> Debug for PasswordMasked<'_, RiAbsoluteStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiAbsoluteStr<S>>
source§impl<S: Spec> Debug for PasswordMasked<'_, RiReferenceStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiReferenceStr<S>>
source§impl<S: Spec> Debug for PasswordMasked<'_, RiRelativeStr<S>>
impl<S: Spec> Debug for PasswordMasked<'_, RiRelativeStr<S>>
source§impl<S: Spec> Display for PasswordMasked<'_, RiAbsoluteStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiAbsoluteStr<S>>
source§impl<S: Spec> Display for PasswordMasked<'_, RiReferenceStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiReferenceStr<S>>
source§impl<S: Spec> Display for PasswordMasked<'_, RiRelativeStr<S>>
impl<S: Spec> Display for PasswordMasked<'_, RiRelativeStr<S>>
source§impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiAbsoluteStr<S>>
Available on crate feature alloc
only.
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiAbsoluteStr<S>>
alloc
only.source§type Target = RiAbsoluteString<S>
type Target = RiAbsoluteString<S>
source§fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
source§fn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
source§impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiReferenceStr<S>>
Available on crate feature alloc
only.
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiReferenceStr<S>>
alloc
only.source§type Target = RiReferenceString<S>
type Target = RiReferenceString<S>
source§fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
source§fn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
source§impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiRelativeStr<S>>
Available on crate feature alloc
only.
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiRelativeStr<S>>
alloc
only.source§type Target = RiRelativeString<S>
type Target = RiRelativeString<S>
source§fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
source§fn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
source§impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiStr<S>>
Available on crate feature alloc
only.
impl<S: Spec> ToDedicatedString for PasswordMasked<'_, RiStr<S>>
alloc
only.source§fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
fn try_to_dedicated_string(&self) -> Result<Self::Target, TryReserveError>
source§fn to_dedicated_string(&self) -> Self::Target
fn to_dedicated_string(&self) -> Self::Target
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>
impl<'a, T> Sync for PasswordMasked<'a, T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
source§fn 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.