Skip to content

firma_fs (root module)

Structs

  • FsError - Error returned by file write helpers.

Enums

Functions

  • create_private_dir_all - Create path and all parents with mode 0700 on Unix (umask-independent).
  • write_file - Write bytes to path, creating or truncating it, with the given Unix
  • write_new_file - Write bytes to a new file at path with the given Unix mode.
  • write_private_file - Write contents to path with private permissions on Unix.

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>

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

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.

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>

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].

Returns [FsError] on any I/O failure.

fn write_file(path: &std::path::Path, bytes: &[u8], mode: u32) -> Result<(), FsError>

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.

Returns [FsError] on any I/O failure.

fn write_new_file(path: &std::path::Path, bytes: &[u8], mode: u32) -> Result<(), FsError>

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.

Returns an [io::Error] on any I/O failure.

fn write_private_file(path: &std::path::Path, contents: &[u8]) -> io::Result<()>