pub struct FileStorage { /* private fields */ }Expand description
A pairing store in one JSON file, behind the storage-file feature.
Creating it creates the file if it is absent and checks one that exists: a file that is not
this backend’s format, including one with a version this build does not know, is refused
with an error and never rewritten. Every write goes to a temporary file in the same
directory and is renamed over the store, so an interrupted write leaves the previous store
intact. On Unix the file is created with mode 0600.
The backend holds no records in memory: every call reads the file, and writes hold a lock so two callers in one process cannot lose each other’s record. One process owns the file; a second process writing the same path at the same time is not coordinated, which matches the client’s one-connection design.
Implementations§
Source§impl FileStorage
impl FileStorage
Sourcepub fn new(path: impl Into<PathBuf>) -> Result<Self>
pub fn new(path: impl Into<PathBuf>) -> Result<Self>
Opens the store at path, creating it when it does not exist.
The parent directory must exist; this backend creates a file, never a directory. An existing file must be a store of the shape this build writes, or the call returns an error and the file is left untouched.
Trait Implementations§
Source§impl Debug for FileStorage
impl Debug for FileStorage
Source§impl Storage for FileStorage
impl Storage for FileStorage
Source§fn pairing_psk(&self) -> Result<Option<[u8; 32]>>
fn pairing_psk(&self) -> Result<Option<[u8; 32]>>
None on a device’s first run. Read more