Skip to content

Commit fa05fe3

Browse files
committedApr 3, 2024·
Document no-panic behavior
1 parent 18e305b commit fa05fe3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed
 

‎README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# femtopb
22

3-
A tiny footprint, `#[no_std]`, no-alloc Protobuf serialization library. This allows you to communicate using Protobuf
4-
on constrained platforms, like bare-metal MCUs with very limited RAM.
3+
A tiny footprint, `#[no_std]`, no-alloc, no-panic Protobuf serialization library. This allows you to communicate using
4+
Protobuf on constrained platforms, like bare-metal MCUs with very limited RAM.
55

66
Yes, you heard it right: this library lets you serialize and deserialize Protobuf messages without any dynamic
77
memory/heap allocation.
@@ -10,6 +10,11 @@ The library takes care of using simple types with limited use of generics when p
1010
code size explosion. The runtime also consists of many tiny functions so that the ones that aren't used can get
1111
optimized away.
1212

13+
During testing of this crate, checks are made to ensure that `femtopb` code cannot panic. If you want to leverage the
14+
no-panic checks yourself to debug your own project, enable the `assert-no-panic` crate feature. It is not necessarily a
15+
good idea to enable this feature for your release code, as enabling this feature might change the generated code
16+
slightly.
17+
1318
There are some limitations, however. Messages must be deserialized from continuous `&[u8]` slices, so incremental
1419
deserialization from other `bytes::Buf` types or streams/files/sockets/... is not supported. Also, messages borrow
1520
their source slice for the duration of their lifetime. Deserialization of repeated fields happens lazily to avoid

‎src/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#![cfg_attr(not(test), no_std)]
22
//! # `femtopb`
33
//!
4-
//! A tiny footprint, `#[no_std]`, no-`alloc` Protobuf serialization library. This allows you to
5-
//! communicate using Protobuf on constrained platforms, like bare-metal MCUs with very limited RAM.
4+
//! A tiny footprint, `#[no_std]`, no-`alloc`, no-panic Protobuf serialization library. This allows
5+
//! you to communicate using Protobuf on constrained platforms, like bare-metal MCUs with very
6+
//! limited RAM.
67
//!
78
//! Yes, you heard it right: this library lets you serialize and deserialize Protobuf messages
89
//! without any dynamic memory/heap allocation.
@@ -11,6 +12,11 @@
1112
//! avoid monomorphization code size explosion. The runtime also consists of many tiny functions
1213
//! so that the ones that aren't used can get optimized away.
1314
//!
15+
//! During testing of this crate, checks are made to ensure that `femtopb` code cannot panic. If
16+
//! you want to leverage the no-panic checks yourself to debug your own project, enable the
17+
//! `assert-no-panic` crate feature. It is not necessarily a good idea to enable this feature for
18+
//! your release code, as enabling this feature might change the generated code slightly.
19+
//!
1420
//! ## Defining message types
1521
//!
1622
//! `femtopb` enables encoding and decoding of messages by deriving the `femtopb::Message` trait.

0 commit comments

Comments
 (0)
Please sign in to comment.