Enum sss_rs::wrapped_sharing::Secret[][src]

pub enum Secret {
    InMemory(Vec<u8>),
    InFile(PathBuf),
}
Expand description

Contains the secret, whether in file or in memory stored in a Vec of bytes.

This can be used for both sharing and reconstructing. When reconstructing, you can set it to reconstruct into a Vec by setting it to InMemory, or you can set it to output to a file. For sharing, you can input a secret to be shared, either a file or a vec of bytes.

For example, setting it to empty in memory, and then reconstructing it, will place the reconstructed value in memory, whereas setting it to a file will place it in the path of the given file.

Variants

InMemory(Vec<u8>)

Tuple Fields of InMemory

0: Vec<u8>
InFile(PathBuf)

Tuple Fields of InFile

0: PathBuf

Implementations

Constructs an empty vec for the secret.

Constructs an empty vec for the secret but allocates an intial capacity.

(u8, u8)s the secret to a file. This file can either be a source for the secret, or an output file for reconstructing a secret

Attempts to get the length of the Secret.

This can fail if the secret is a file path that doesn’t exist.

Calculates and returns the Sha3-512 hash of the first 64 bytes of the secret.

This is mainly used for verifying secret reconstruction, where the chances of incorrect reconstruction resulting in the first 64 bytes being correct is extremely low.

If $secret.len() is less than 64 bytes, then only $secret.len() number of bytes is used.

Calculcates and returns the hash of the first 64 bytes of the share in a string with hexidecimal digits.

Calculates a hash and compares it to the given hash. Returns Ok(true) if they’re equivalent, Ok(false) if they aren’t or an error if there was an issue calculating the hash (likely a read error if Secret was a file)

Unwrap and return the inner vec, consuming the secret.

This will panic if the underlying secret is InFile.

Unwrap and clone the inner vec.

This will panic if the underlying secret is InFile

Try to unwrap and return the inner vec.

This does not consume self, since it may return None.

If the secret is returned, an empty vec is put in its place.

Returns None if the inner value is a path, else returns the secret.

Try to unwrap and clone the inner vec.

This does not consume self since it may return None.

Returns None if the inner value is a path, else returns the secret.

Unwrap if InMemory, or read into a Vec if it is InFile.

This will return an Error if the file length is too large to fit into a Vec, or if the file path is invalid.

Unwrap and clone if InMemory, or read into a Vec if it is InFile.

This will return an Error if the file length is too large to fit into a Vec, or if the file path is invalid.

Trait Implementations

Formats the value using the given formatter. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. 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

Performs the conversion.

Performs the conversion.

Should always be Self

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.