Struct prs_lib::types::Plaintext [−][src]
pub struct Plaintext(_);
Plaintext.
Wraps plaintext bytes. This type is limited on purpose, to prevent accidentally leaking the
plaintext. Security properties are enforced by secstr::SecVec.
Implementations
impl Plaintext[src]
impl Plaintext[src]pub fn empty() -> Self[src]
New empty plaintext.
pub fn unsecure_ref(&self) -> &[u8][src]
Get unsecure reference to inner data.
Warning
Unsecure because we cannot guarantee that the referenced data isn’t cloned. Use with care!
The reference itself is safe to use and share. Data may be cloned from this reference
though, when that happens we lose track of it and are unable to securely handle it in
memory. You should clone Plaintext instead.
pub fn unsecure_to_str(&self) -> Result<&str, Utf8Error>[src]
Get the plaintext as UTF8 string.
Warning
Unsecure because we cannot guarantee that the referenced data isn’t cloned. Use with care!
The reference itself is safe to use and share. Data may be cloned from this reference
though, when that happens we lose track of it and are unable to securely handle it in
memory. You should clone Plaintext instead.
pub fn first_line(self) -> Result<Plaintext>[src]
Get the first line of this secret as plaintext.
Returns empty plaintext if there are no lines.
pub fn except_first_line(self) -> Result<Plaintext>[src]
Get all lines execpt the first one.
Returns empty plaintext if there are no lines.
pub fn property(self, property: &str) -> Result<Plaintext>[src]
Get line with the given property.
Returns line with the given property. The property prefix is removed, and only the trimmed value is returned. Returns an error if the property does not exist.
This will never return the first line being the password.
pub fn append(&mut self, other: Plaintext, newline: bool)[src]
Append other plaintext.
Optionally adds platform newline.
pub fn is_empty(&self) -> bool[src]
Check whether this plaintext is empty.
- Empty if 0 bytes
- Empty if bytes parsed as UTF-8 has trimmed length of 0 characters (ignored on encoding failure)
Trait Implementations
impl StructuralEq for Plaintext[src]
impl StructuralEq for Plaintext[src]impl StructuralPartialEq for Plaintext[src]
impl StructuralPartialEq for Plaintext[src]Auto Trait Implementations
impl RefUnwindSafe for Plaintext
impl RefUnwindSafe for Plaintextimpl UnwindSafe for Plaintext
impl UnwindSafe for PlaintextBlanket Implementations
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme, type Err = NoError
The error type produced by a failed conversion.
pub fn approx_from(
src: Src
) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
src: Src
) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme, type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
pub fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
impl<T> ConvUtil for T
impl<T> ConvUtil for Tpub fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
pub fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
pub fn into_as<Dst>(self) -> Dst where
Self: Into<Dst>,
Self: Into<Dst>,
pub fn try_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: TryInto<Dst>,
Self: TryInto<Dst>,
pub fn value_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ValueInto<Dst>,
Self: ValueInto<Dst>,
impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Srctype Err = NoError
The error type produced by a failed conversion.
pub fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>, type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.