Expand description

Stor trait defines underlying storage for use in type definitions

use stor::Stor;
 
/// Generic object over storage types
enum Something<S: Stor<()>> {
  List(S::List),
  Str(S::String),
  Bytes(S::Bytes),
}
 
/// Owned version (requires `alloc` feature)
type SomethingOwned = Something<stor::Owned>;
let _ = SomethingOwned::Str("hello".to_string());
let _ = SomethingOwned::Bytes(vec![0xaa, 0xbb, 0xcc]);
 
/// Reference version
type SomethingRef<'a> = Something<stor::Ref<'a>>;
let _ = SomethingRef::Str("hello");
let _ = SomethingRef::Bytes(&[0xaa, 0xbb, 0xcc]);
 
/// Const N version
type SomethingConst<'a> = Something<stor::Const<3>>;
let _ = SomethingConst::Str("hello");
let _ = SomethingConst::Bytes([0xaa, 0xbb, 0xcc]);

Structs

Const marker uses const size containers

Heapless marker uses heapless containers

Owned marker uses alloc backed storage

Ref marker uses &'a T containers

Traits

Stor trait defines types for references