Support no_std in roto-runtime
Add #![no_std] to the runtime crate and introduce optional std and alloc features. Update the code generator to be compatible and add a no_std_test example. Remove the generator binary.
This commit is contained in:
+6
-1
@@ -4,4 +4,9 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bytes = "1.7"
|
||||
bytes = { version = "1.7", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std", "alloc"]
|
||||
std = []
|
||||
alloc = []
|
||||
|
||||
+9
-3
@@ -1,4 +1,9 @@
|
||||
use std::fmt;
|
||||
#![no_std]
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate std;
|
||||
|
||||
use core::fmt;
|
||||
use bytes::BufMut;
|
||||
|
||||
pub struct MapFieldIterator<'a> {
|
||||
@@ -51,9 +56,10 @@ impl fmt::Display for RotoError {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for RotoError {}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, RotoError>;
|
||||
pub type Result<T> = core::result::Result<T, RotoError>;
|
||||
|
||||
pub trait RotoOwned {
|
||||
type Reader<'a> where Self: 'a;
|
||||
@@ -686,7 +692,7 @@ mod tests {
|
||||
.iter_repeated(18)
|
||||
.map(|r| {
|
||||
let (val, _) = r.expect("Failed to decode repeated string");
|
||||
std::str::from_utf8(val).expect("Invalid utf8")
|
||||
core::str::from_utf8(val).expect("Invalid utf8")
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(repeated_strings, vec!["one", "two", "three"]);
|
||||
|
||||
Reference in New Issue
Block a user