firma_fs (root module)
Module: firma_fs
Section titled “Module: firma_fs”Contents
Section titled “Contents”Structs
FsError- Error returned by file write helpers.
Enums
CreatePrivateDirError- Error returned by [create_private_dir_all].
Functions
create_private_dir_all- Createpathand all parents with mode 0700 on Unix (umask-independent).write_file- Writebytestopath, creating or truncating it, with the given Unixwrite_new_file- Writebytesto a new file atpathwith the given Unix mode.write_private_file- Writecontentstopathwith private permissions on Unix.
firma_fs::CreatePrivateDirError
Section titled “firma_fs::CreatePrivateDirError”Enum
Error returned by [create_private_dir_all].
Variants:
Create{ path: std::path::PathBuf, source: io::Error }- Directory creation failed.Chmod{ path: std::path::PathBuf, source: io::Error }- Setting mode 0700 on an existing directory failed.
Trait Implementations:
- Display
fn fmt(self: &Self, __formatter: & mut ::core::fmt::Formatter) -> ::core::fmt::Result
- Debug
fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result
- Error
fn source(self: &Self) -> ::core::option::Option<&dyn ::thiserror::__private18::Error>
firma_fs::FsError
Section titled “firma_fs::FsError”Struct
Error returned by file write helpers.
Methods:
fn kind(self: &Self) -> io::ErrorKind- Return the underlying I/O error kind.
Trait Implementations:
- Display
fn fmt(self: &Self, __formatter: & mut ::core::fmt::Formatter) -> ::core::fmt::Result
- Error
fn source(self: &Self) -> ::core::option::Option<&dyn ::thiserror::__private18::Error>
- Debug
fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result
firma_fs::create_private_dir_all
Section titled “firma_fs::create_private_dir_all”Function
Create path and all parents with mode 0700 on Unix (umask-independent).
Also enforces 0700 on the final directory when it already exists.
On non-Unix platforms, falls back to [std::fs::create_dir_all] without
explicit mode handling.
Errors
Section titled “Errors”Returns [CreatePrivateDirError::Create] if the directory cannot be created,
or [CreatePrivateDirError::Chmod] if its permissions cannot be set to 0700.
fn create_private_dir_all(path: &std::path::Path) -> Result<(), CreatePrivateDirError>firma_fs::write_file
Section titled “firma_fs::write_file”Function
Write bytes to path, creating or truncating it, with the given Unix
mode.
On non-Unix platforms, the mode argument is ignored. See the
module docs for when to use this helper instead of
[write_private_file] or [write_new_file].
Errors
Section titled “Errors”Returns [FsError] on any I/O failure.
fn write_file(path: &std::path::Path, bytes: &[u8], mode: u32) -> Result<(), FsError>firma_fs::write_new_file
Section titled “firma_fs::write_new_file”Function
Write bytes to a new file at path with the given Unix mode.
Returns [FsError] with [FsError::kind] equal to
[io::ErrorKind::AlreadyExists] if the file already exists. Callers decide
whether to treat that as an error or ignore it.
On non-Unix platforms, the mode argument is ignored. See the
module docs for the shared parent-directory requirement.
Errors
Section titled “Errors”Returns [FsError] on any I/O failure.
fn write_new_file(path: &std::path::Path, bytes: &[u8], mode: u32) -> Result<(), FsError>firma_fs::write_private_file
Section titled “firma_fs::write_private_file”Function
Write contents to path with private permissions on Unix.
Uses O_CREAT | O_TRUNC so the mode is set atomically on creation, then
reapplies mode 0600 after writing to tighten pre-existing files. Falls back
to [std::fs::write] on non-Unix platforms. See the module docs
for helper-selection guidance and parent-directory requirements.
Errors
Section titled “Errors”Returns an [io::Error] on any I/O failure.
fn write_private_file(path: &std::path::Path, contents: &[u8]) -> io::Result<()>