6 releases
0.1.5 | Mar 20, 2023 |
---|---|
0.1.4 | Jul 18, 2022 |
#28 in #leveldb
32 downloads per month
Used in 2 crates
(via leveldb-orm)
7KB
88 lines
Use LeveldbOrm
+ leveldb_key
to auto impl trait in leveldb-orm
#[derive(LeveldbOrm)]
#[leveldb_key(executable, args)]
struct Command {
pub executable: u8,
pub args: Vec<String>,
pub current_dir: Option<String>,
}
Generate code
impl<'a> leveldb_orm::KeyOrm<'a> for Command {
type KeyType = (u8, Vec<String>);
type KeyTypeRef = (&'a u8, &'a Vec<String>);
#[inline]
fn key(
&self,
) -> std::result::Result<leveldb_orm::EncodedKey<Self>, Box<dyn std::error::Error>> {
Self::encode_key((&self.executable, &self.args))
}
}
lib.rs
:
Use LeveldbOrm
+ leveldb_key
to auto impl trait in leveldb-orm
use leveldb_orm::LeveldbOrm;
#[derive(LeveldbOrm)]
#[leveldb_key(executable, args)]
struct Command {
pub executable: u8,
pub args: Vec<String>,
pub current_dir: Option<String>,
}
// Generate code
// impl<'a> leveldb_orm::KeyOrm<'a> for Command {
// type KeyType = (u8, Vec<String>);
// type KeyTypeRef = (&'a u8, &'a Vec<String>);
// #[inline]
// fn key(
// &self,
// ) -> std::result::Result<leveldb_orm::EncodedKey<Self>, Box<dyn std::error::Error>> {
// Self::encode_key((&self.executable, &self.args))
// }
// }
Dependencies
~255–700KB
~17K SLoC