Skip to main content

FileStore

Struct FileStore 

Source
pub struct FileStore<L = TenantLayout> { /* private fields */ }
Expand description

A SecretStore kept in one file.

See the module documentation for what protects the values in it and what does not — the short answer is the current OS identity plus native owner-only filesystem controls, and nothing cryptographic.

Implementations§

Source§

impl FileStore

Source

pub fn open(path: impl Into<PathBuf>) -> Result<FileStore, StoreError>

Open — or create — the store at path, using the blessed TenantLayout.

On Unix the containing directory is created at 0700 and the file at 0600. On Windows both are created for the process TokenUser SID with a protected DACL allowing only that SID. Existing state with a foreign owner, wider access, a link/reparse point, the wrong kind or uninspectable metadata is refused, never tightened or repaired: it may already have exposed values, and changing it silently would hide that evidence.

§Errors

StoreError::Unreachable for an IO or security-inspection failure, StoreError::Denied for native protection this store will not use, and StoreError::Backend for a file it cannot parse. Every one names the filesystem path and none carries a value.

Source§

impl<L> FileStore<L>
where L: Layout,

Source

pub fn open_with_layout( path: impl Into<PathBuf>, layout: L, ) -> Result<FileStore<L>, StoreError>

Open — or create — the store at path, rendering addresses through layout.

§Errors

As FileStore::open.

Source

pub fn stale_temporaries(&self) -> Vec<PathBuf>

Every unfinished temporary sitting beside this store, in no particular order.

Public so the reaping above is observable rather than merely asserted — a test can plant one, see it listed, open the store and see the list empty.

Source

pub fn path(&self) -> &Path

The file this store is kept in.

Source

pub fn layout(&self) -> &L

The layout this store renders through.

Source

pub fn address(&self, reference: &CredentialRef) -> String

The path reference resolves to under this store’s layout.

The address, not the file — the same question MemoryStore::path answers.

Source

pub fn reference(&self, path: &str) -> Result<CredentialRef, StoreError>

The address a rendered path resolves back to — the inverse of address.

§Errors

StoreError::Layout, carrying the layout’s own explanation, when the path is not one this layout writes.

Source

pub fn paths(&self) -> Vec<String>

Every address currently holding a value, in order. Values are deliberately not exposed.

Source

pub fn len(&self) -> usize

How many values are held.

Source

pub fn is_empty(&self) -> bool

Whether the store holds nothing.

Trait Implementations§

Source§

impl<L> Debug for FileStore<L>

Path and entry count. Never a value, and never an address — a derived Debug would print every key, and C-159 is this repository’s precedent for a derived rendering becoming the leak.

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<L> Drop for FileStore<L>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<L> PreparedSecretStore for FileStore<L>
where L: Layout + Send + Sync,

Source§

fn prepare<'life0, 'life1, 'async_trait>( &'life0 self, id: SecretTransactionId, digest: SecretProposalDigest, mutations: &'life1 SecretBatch, ) -> Pin<Box<dyn Future<Output = Result<SecretTransactionState, PreparedSecretError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FileStore<L>: 'async_trait,

Source§

fn state<'life0, 'async_trait>( &'life0 self, id: SecretTransactionId, ) -> Pin<Box<dyn Future<Output = Result<SecretTransactionState, PreparedSecretError>> + Send + 'async_trait>>
where 'life0: 'async_trait, FileStore<L>: 'async_trait,

Source§

fn commit<'life0, 'async_trait>( &'life0 self, id: SecretTransactionId, ) -> Pin<Box<dyn Future<Output = Result<SecretTransactionState, PreparedSecretError>> + Send + 'async_trait>>
where 'life0: 'async_trait, FileStore<L>: 'async_trait,

Source§

fn abort<'life0, 'async_trait>( &'life0 self, id: SecretTransactionId, ) -> Pin<Box<dyn Future<Output = Result<SecretTransactionState, PreparedSecretError>> + Send + 'async_trait>>
where 'life0: 'async_trait, FileStore<L>: 'async_trait,

Source§

fn reclaim<'life0, 'async_trait>( &'life0 self, through: SecretTransactionGeneration, ) -> Pin<Box<dyn Future<Output = Result<(), PreparedSecretError>> + Send + 'async_trait>>
where 'life0: 'async_trait, FileStore<L>: 'async_trait,

Source§

impl<L> SecretStore for FileStore<L>
where L: Layout + Send + Sync,

Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, reference: &'life1 CredentialRef, ) -> Pin<Box<dyn Future<Output = Result<Secret, StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FileStore<L>: 'async_trait,

Read the value at reference. Read more
Source§

fn put<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, reference: &'life1 CredentialRef, secret: &'life2 Secret, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, FileStore<L>: 'async_trait,

Write secret at reference, replacing whatever was there. Read more
Source§

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, reference: &'life1 CredentialRef, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FileStore<L>: 'async_trait,

Remove whatever is stored at reference. Read more
Source§

fn references<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 CredentialScope, ) -> Pin<Box<dyn Future<Output = Result<Vec<CredentialRef>, StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FileStore<L>: 'async_trait,

List the addresses inside scope, never their values. Read more
Source§

fn apply<'life0, 'life1, 'async_trait>( &'life0 self, mutations: &'life1 SecretBatch, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, FileStore<L>: 'async_trait,

Apply every mutation in batch atomically, or expose none of them.

Auto Trait Implementations§

§

impl<L = TenantLayout> !Freeze for FileStore<L>

§

impl<L> RefUnwindSafe for FileStore<L>
where L: RefUnwindSafe,

§

impl<L> Send for FileStore<L>
where L: Send,

§

impl<L> Sync for FileStore<L>
where L: Sync,

§

impl<L> Unpin for FileStore<L>
where L: Unpin,

§

impl<L> UnsafeUnpin for FileStore<L>
where L: UnsafeUnpin,

§

impl<L> UnwindSafe for FileStore<L>
where L: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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