A better Rust ATProto crate
102
fork

Configure Feed

Select the types of activity you want to include in your feed.

at pretty-codegen 21 lines 989 B view raw
1use crate::io; 2 3#[cfg(not(feature = "alloc"))] 4pub type Vec<T> = heapless::Vec<T, 256>; 5 6/// Backing key-value storage trait. 7/// This allows the collection type to be backed by filesystem, database, or other secondary storage. 8/// Keys are intentionally just byte slices for flexibilty. 9/// On no-alloc the returned vector caps out at 256 bytes and is stored on the stack. 10/// Intended return path fordata is via the types that return `RW` 11/// `RW`: should be a reader, preferably seekable. 12pub trait Storage { 13 fn get<RW>(&self, key: &[u8]) -> io::Result<Option<RW>>; 14 fn get_data(&self, key: &[u8]) -> io::Result<Option<Vec<u8>>>; 15 fn put_data(&self, key: &[u8], value: &[u8]) -> io::Result<()>; 16 fn put<RW>(&self, key: &[u8], value: RW) -> io::Result<()>; 17 fn has(&self, key: &[u8]) -> io::Result<bool>; 18 fn del(&self, key: &[u8]) -> io::Result<()>; 19 fn buffer(&self, key: &[u8]) -> &mut [u8]; 20 fn writer(&self, key: &[u8]) -> io::Result<Box<dyn io::Write>>; 21}