Skip to content

Commit

Permalink
Add object-safe traits for File, Filesystem, Storage
Browse files Browse the repository at this point in the history
The Storage trait is not object safe, and the File and Filesystem struct
have the Storage implementation as a type parameter.  This can make it
hard to write code that works with multiple storage implementations, and
it can also lead to increased binary size as the filesystem operations
are monomorphized for all storage implementations.

This patch introduces three new traits, DynFile, DynFilesystem and
DynStorage, that are object-safe wrappers for the File, Filesystem and
Storage types.  Some functionality cannot be expressed directly in these
traits and is moved into helper functions instead, e. g. callbacks with
arbitrary return types or methods using const generics.
  • Loading branch information
robin-nitrokey committed Dec 15, 2023
1 parent 9c2d48d commit 75a3b35
Show file tree
Hide file tree
Showing 3 changed files with 387 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## Added
- Added object-safe traits `DynFile`, `DynFilesystem` and `DynStorage` for
accessing `Storage`, `Filesystem` and `File` implementations for any storage.

## Fixed

- Fixed macro hygiene for `path!`.
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ mod c_stubs;

pub mod consts;
pub mod driver;

pub mod fs;
pub mod io;
pub mod object_safe;
pub mod path;

/// get information about the C backend
Expand Down
Loading

0 comments on commit 75a3b35

Please sign in to comment.