Expand description
Pinecone, a minimalistic no_std
+ alloc
serde format
Works just like any other normal serde:
use pinecone::{from_bytes, to_slice, to_vec};
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Example {
foo: String,
bar: Option<u32>,
zot: bool,
}
let original = Example {
foo: "Vec test".to_string(),
bar: Some(0x1337),
zot: true,
};
let bytes: Vec<u8> = to_vec(&original).expect("Serialization failed");
assert_eq!(from_bytes(&bytes), Ok(original));
let original = Example {
foo: "Slice test".to_string(),
bar: Some(0x1337),
zot: true,
};
let mut buffer = [0; 1024];
to_slice(&original, &mut buffer).expect("Serialization failed");
assert_eq!(from_bytes(&buffer), Ok(original));
Structs§
- Deserializer
- A structure for deserializing a pinecone message
- Serializer
- A
serde
compatible serializer
Enums§
- Error
- This is the error type used by Pinecone
Functions§
- from_
bytes - Deserialize a message of type
T
from a byte slice. The unused portion (if any) of the byte slice is discarded - take_
from_ bytes - Deserialize a message of type
T
from a byte slice. The unused portion (if any) of the byte slice is returned for further usage - to_
slice - Serialize a
T
to the given slice, with the resulting slice containing data in a serialized format. - to_vec
- Serialize a
T
to a `Vec
Type Aliases§
- Result
- This is the Result type used by Pinecone.