mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-18 17:26:16 +00:00
Migrate BlockRc and BlockResyncManager to TypedTree
This commit is contained in:
@@ -155,6 +155,21 @@ pub fn gen_uuid() -> Uuid {
|
||||
rand::rng().random::<[u8; 32]>().into()
|
||||
}
|
||||
|
||||
impl garage_db::DbBytes for FixedBytes32 {
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
self.0.into()
|
||||
}
|
||||
fn decode(bytes: &[u8]) -> std::result::Result<Self, garage_db::DecodeError> {
|
||||
Self::try_from(bytes).ok_or_else(|| {
|
||||
garage_db::DecodeError(
|
||||
format!("invalid hash: expected 32 bytes, got {}", bytes.len()).into(),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl garage_db::DbOrdKey for FixedBytes32 {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -79,6 +79,18 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<garage_db::DbError> for Error {
|
||||
fn from(e: garage_db::DbError) -> Error {
|
||||
Error::Db(e.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<garage_db::DecodeError> for Error {
|
||||
fn from(e: garage_db::DecodeError) -> Error {
|
||||
Error::Db(e.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<garage_db::TxError<Error>> for Error {
|
||||
fn from(e: garage_db::TxError<Error>) -> Error {
|
||||
match e {
|
||||
|
||||
Reference in New Issue
Block a user