Commit Graph

142 Commits

Author SHA1 Message Date
Robin Krahl
c31e789cd7 Release littlefs2-core v0.1.1 core-0.1.1 2025-01-16 16:41:11 +01:00
Robin Krahl
de820834f0 core: Add path_buf macro
We already have the path macro and PathBuf::from_path.  Having a
separate path_buf macro makes the code more readable and ensures
compile-time evaluation.
2025-01-16 16:41:09 +01:00
Robin Krahl
51cae4d5fd core: Make Path and PathBuf more const-friendly
This patch makes Path and PathBuf more const-friendly by adding some new
const methods and marking existing methods as const.
2025-01-16 16:24:36 +01:00
Robin Krahl
45e87d5e25 Remove empty line after doc comment
This fixes a new clippy lint.
2025-01-07 12:25:28 +01:00
Robin Krahl
b868aa6c92 Remove unnecessary explicit lifetimes
This fixes a new clippy lint.
2025-01-07 12:25:07 +01:00
Robin Krahl
62afcd88fc Add list example
This patch adds an example that reads a filesystem image from a file and
prints its content.
2024-11-17 21:40:45 +01:00
Robin Krahl
0a22aa1101 Release v0.5.0 0.5.0 2024-10-25 10:57:54 +02:00
Robin Krahl
7614f8e18b Handle platforms where c_int is not i32
Some functions assume that c_int is always i32.  This is not true for
all platforms.  This patch adapts those functions to handle those cases.

Some littlefs functions return an error code (c_int) from functions
returning i32.  In these cases, error codes are truncated to c_int::MIN.
2024-10-22 17:00:42 +02:00
Robin Krahl
0988ecd8a8 Add CI job for avr target 2024-10-22 16:58:41 +02:00
Robin Krahl
0d753af154 Release littlefs2-core v0.1.0 core-0.1.0 2024-10-17 10:58:24 +02:00
Robin Krahl
d86f5fa7ab core: Never inline Path to PathBuf conversion 2024-10-15 14:07:51 +02:00
Robin Krahl
bea46411a1 core: Remove debug information from Error
If unwrap or expect is used on a Result<_, Error>, the Debug
implementation is not always optimized out.  This leads to a significant
increase of the binary size. As a short-term fix, this patch changes the
Debug implementation to always returns a static string.
2024-10-14 21:23:41 +02:00
Robin Krahl
a1f8d9e87b core: Add support for heapless-bytes
Similar to the existing support for multiple heapless versions, this
patch also adds support for heapless-bytes 0.3 and 0.4.
2024-09-13 11:44:54 +02:00
Robin Krahl
932a40f2da core: Make heapless support optional and support multiple versions
The DynFile::read_to_end, DynFilesystem::read and
DynFilesystem::read_chunk methods use a heapless::Vec to store a
flexible amount of data.  This patch introduces a Vec trait that
abstracts over different versions of heapless so that we can optionally
support multiple heapless versions at the same time.

Fixes: https://github.com/trussed-dev/littlefs2/issues/77
2024-09-13 11:44:33 +02:00
Robin Krahl
e225f060e5 Remove unnecessary clone in ReadDir 2024-09-13 11:04:13 +02:00
Robin Krahl
69ff97406d Remove dir-entry-path feature
The dir-entry-path feature has been enabled by default and only adds a
very small overhead.  To decrease complexity, this patch removes the
feature and always enables the previously feature-gated code.

Fixes: https://github.com/trussed-dev/littlefs2/issues/76
2024-09-13 11:04:11 +02:00
Robin Krahl
e21c691032 Refactor attributes API
This patch refactory the API to read and write attributes so that the
buffer is always provided by the caller.  This means that the caller is
not required to always use a 1 kB buffer even if the attribute length is
much smaller.

Fixes: https://github.com/trussed-dev/littlefs2/issues/75
2024-08-16 12:01:03 +02:00
Robin Krahl
85ac8165d0 core: Use c_int where applicable
This patch applies those changes from
https://github.com/trussed-dev/littlefs2/pull/69 that affect the core
crate.
2024-08-15 08:47:07 +02:00
Robin Krahl
95fd60a59c core: Move size constants into associated constants
To reduce the number of global items and for consistency with constants
like u8::MAX, this patch replaces the size constants ATTRBYTES_MAX,
PATH_MAX and PATH_MAX_PLUS_ONE with associated constants
Attribute::MAX_SIZE, PathBuf::MAX_SIZE and PathBuf::MAX_SIZE_PLUS_ONE.
2024-08-12 08:30:28 +02:00
Robin Krahl
ce4809097a core: Remove generic-array dependency
By refactoring the Attribute struct using const generics, we can get rid
of the (public) generic-array dependency.
2024-08-12 08:30:28 +02:00
Robin Krahl
7356da54d1 Introduce littlefs2-core crate
To make it easier to maintain applications using littlefs2, this patch
introduces a littlefs2-core crate with the basic types and traits used
by littlefs2, but without a specific implementation.

Fixes: https://github.com/trussed-dev/littlefs2/issues/55
2024-08-12 08:30:25 +02:00
Robin Krahl
97a7939437 Use FileOpenFlags instead of OpenOptions in DynFilesystem
Previously, DynFilesystem used OpenOptions for opening files in a custom
mode.  This has two drawbacks:  OpenOptions are constructed using a
callback leading to a rather complex method signature.  And OpenOption
depends on the Filesystem type, making it impossible to move
DynFilesystem into a separate core crate without also moving Filesystem.

This patch makes the FileOpenFlags struct public, changes its backing
type to i32 to avoid unnecessary conversions and changes the
DynFilesystem trait to accept FileOpenFlags instead of an
OpenOptionsCallback.  The affected methods are renamed from
*with_options* to *with_flags*.
2024-08-12 08:28:04 +02:00
Robin Krahl
f6b90f52b3 Extend CI checks
This patch adds clippy and rustfmt to the CI and fails the workflow if
cargo doc shows a warning.
2024-08-08 17:58:25 +02:00
Robin Krahl
e6435d207d Move exists method from Path into Filesystem
The Path::exists method requires access to a Filesystem instance.  This
will be a problem once we move Path into a separate core crate (that
does not have access to the Filesystem implementation).  Therefore, this
patch replaces Path::exists with Filesystem::exists.
2024-08-08 08:39:31 +02:00
Robin Krahl
ee539c764a Replace Error enum with struct
To make it easier to add support for new error codes without breaking
compatibility, this patch replaces the Error enum with a struct and
associated constants.  As a part of this change, it also enforces that
Error is not used for return values indicating success, i. e. only for
negative return values.
2024-07-04 10:34:36 +02:00