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]

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 Clone for Plaintext[src]

impl Eq for Plaintext[src]

impl From<&'_ str> for Plaintext[src]

impl From<String> for Plaintext[src]

impl From<Vec<u8, Global>> for Plaintext[src]

impl PartialEq<Plaintext> for Plaintext[src]

impl StructuralEq for Plaintext[src]

impl StructuralPartialEq for Plaintext[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
    Scheme: ApproxScheme, 

type Err = NoError

The error type produced by a failed conversion.

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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, Dst> ConvAsUtil<Dst> for T

impl<T> ConvUtil for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<Src> TryFrom<Src> for Src

type Err = NoError

The error type produced by a failed conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<Src, Dst> TryInto<Dst> for Src where
    Dst: TryFrom<Src>, 

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<Src> ValueFrom<Src> for Src

type Err = NoError

The error type produced by a failed conversion.

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.