Skip to content

Commit dcf54b6

Browse files
committed
move CodecInfo and EncodingInfo here
Signed-off-by: Dave Huseby <[email protected]>
1 parent 5ebf81b commit dcf54b6

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "multitrait"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["Dave Huseby <[email protected]>"]
66
description = "Multiformat traits"
@@ -9,5 +9,7 @@ readme = "README.md"
99
license = "Apache-2.0"
1010

1111
[dependencies]
12+
multibase = "0.9"
13+
multicodec = { version = "0.2", git = "https://github.com/cryptidtech/rust-multicodec.git" }
1214
thiserror = "1.0"
1315
unsigned-varint = { version = "0.8", features = ["std"] }

src/codec_info.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use crate::prelude::Codec;
2+
3+
/// This trait exposes the codec information for multicoded types
4+
pub trait CodecInfo {
5+
/// return the preferred codec associated with this object
6+
fn preferred_codec() -> Codec;
7+
8+
/// return the actual codec associated with this object
9+
fn codec(&self) -> Codec;
10+
}

src/encoding_info.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use crate::prelude::Base;
2+
3+
/// This trait exposes the preferred encoding for this multicodec type
4+
pub trait EncodingInfo {
5+
/// return the preferred encoding for this multicodec type
6+
fn preferred_encoding() -> Base;
7+
8+
/// return the actual encoding for this multicodec type
9+
fn encoding(&self) -> Base;
10+
}

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ pub mod try_decode_from;
2020
/// one-stop shop for all exported symbols
2121
pub mod prelude {
2222
pub use super::{enc_into::*, try_decode_from::*};
23+
24+
/// re-exports
25+
pub use multibase::Base;
26+
pub use multicodec::prelude::Codec;
2327
}
2428

2529
#[cfg(test)]

0 commit comments

Comments
 (0)