Skip to main content

EncryptedBackendBuilder

Struct EncryptedBackendBuilder 

Source
pub struct EncryptedBackendBuilder<B> { /* private fields */ }
Expand description

Settings of an EncryptedBackend, set through the methods below and applied by build.

encrypt_names, block_size and long_name_threshold are stored in the share’s marker. One that is left alone takes the share’s value, or for a new share the default named on its method. case_insensitive and name_cache_ttl are not stored and default to the values named on their methods.

Implementations§

Source§

impl<B: ShareBackend> EncryptedBackendBuilder<B>

Source

pub fn encrypt_names(self, on: bool) -> Self

Sets whether the names of files and directories are stored encrypted. On for a new share unless set. A value that differs from the share’s fails build with SettingMismatch.

Source

pub fn case_insensitive(self, on: bool) -> Self

Sets whether names match without regard to case. On by default. It applies to encrypted names; with names in the clear the inner backend’s rule decides and this has no effect.

Source

pub fn block_size(self, bytes: u32) -> Self

Sets the number of plaintext bytes in a block: a power of two from 8192 to 1048576. The default for a new share is 65536. Another value fails build with InvalidSetting, and one that differs from the share’s with SettingMismatch.

Source

pub fn long_name_threshold(self, chars: u8) -> Self

Sets the longest stored name in characters, from 62 to 255. A name whose encrypted form is longer is stored under a short name made from a hash, with the encrypted form in a second object beside it. The default for a new share is 255. Another value, or any value together with encrypt_names(false), fails build with InvalidSetting, and one that differs from the share’s with SettingMismatch.

Source

pub fn name_cache_ttl(self, ttl: Duration) -> Self

Sets how long the decrypted names of a directory are trusted for changes made outside this backend. The default is 30 seconds; Duration::ZERO lists the directory again on every lookup that needs it. The setting applies only to encrypted names that match without regard to case.

Source

pub fn restore_marker(self) -> Self

Lets build write a new marker into a root that has entries and no marker. Without it that root fails with MarkerMissing.

The new marker takes the settings set on the builder, else the defaults, so a share made with other settings has to be restored with them. Before it writes the marker, build checks the key and the block size against what the share holds. It does not check encrypt_names or long_name_threshold, so keep a record of them. With encrypted names, at least one entry of the root has to decode under the key, and entries whose names do not decode are passed over. Of the files, the first that holds data, found breadth first among at most 10,000 entries, has to have a header of the chosen block size and a first block that is a hole or verifies under the key. A share with no such file passes. A failed check is KeyMismatch, or SettingMismatch for the block size.

With names in the clear, a stray file such as .DS_Store can be the file that is checked, and fails with KeyMismatch until it is removed.

Source

pub async fn build(self) -> Result<EncryptedBackend<B>, EncryptionError>

Checks the settings and the root of the inner backend, and returns the backend.

An empty root is a new share: build writes the marker, unless the inner backend is read-only. A root with a marker is an existing share: the key has to verify, and the settings set on the builder have to equal the marker’s. Settings not set take the marker’s.

§Errors

Fails with an EncryptionError:

Trait Implementations§

Source§

impl<B> Debug for EncryptedBackendBuilder<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more