-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add compat layer between two cid defs * point back to updated version of atrium-api
- Loading branch information
Showing
4 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use cid::{multihash::Multihash, Cid}; | ||
|
||
pub struct CidOld(cid_old::Cid); | ||
|
||
impl From<cid_old::Cid> for CidOld { | ||
fn from(value: cid_old::Cid) -> Self { | ||
Self(value) | ||
} | ||
} | ||
impl TryFrom<CidOld> for Cid { | ||
type Error = cid::Error; | ||
fn try_from(value: CidOld) -> Result<Self, Self::Error> { | ||
let version = match value.0.version() { | ||
cid_old::Version::V0 => cid::Version::V0, | ||
cid_old::Version::V1 => cid::Version::V1, | ||
}; | ||
|
||
let codec = value.0.codec(); | ||
let hash = value.0.hash(); | ||
let hash = Multihash::from_bytes(&hash.to_bytes())?; | ||
|
||
Self::new(version, codec, hash) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod cid_compat; | ||
pub mod stream; | ||
pub mod subscription; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters