Crate pinecone[−][src]
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
A structure for deserializing a pinecone message
A serde
compatible serializer
Enums
This is the error type used by Pinecone
Functions
Deserialize a message of type T
from a byte slice. The unused portion (if any)
of the byte slice is discarded
Deserialize a message of type T
from a byte slice. The unused portion (if any)
of the byte slice is returned for further usage
Serialize a T
to the given slice, with the resulting slice containing
data in a serialized format.
Serialize a T
to a `Vec
Type Definitions
This is the Result type used by Pinecone.