File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,14 @@ use std::io::{BufRead, Write};
1010/// Each IPLD codec implementation should implement this Codec trait. This way codecs can be more
1111/// easily exchanged or combined.
1212pub trait Codec < T > : Links {
13- /// The multicodec code of the IPLD codec.
14- const CODE : u64 ;
1513 /// The error that is returned if encoding or decoding fails.
1614 type Error ;
1715
16+ /// The multicodec code of the IPLD codec.
17+ fn to_code ( & self ) -> u64 ;
18+ /// Attempt to convert from a `u64` code to this `Codec`.
19+ fn try_from_code ( code : u64 ) -> Option < Self > where Self : Sized ;
20+
1821 /// Decode a reader into the desired type.
1922 fn decode < R : BufRead > ( reader : R ) -> Result < T , Self :: Error > ;
2023 /// Encode a type into a writer.
You can’t perform that action at this time.
0 commit comments