File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use crate::meta::KnownMagic;
88#[ derive( Debug ) ]
99pub enum Error {
1010 CorruptMeta ,
11+ NotRainMetaDocument ,
1112 InvalidHash ,
1213 UnknownMeta ,
1314 UnknownMagic ,
@@ -36,6 +37,9 @@ impl std::fmt::Display for Error {
3637 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3738 match self {
3839 Error :: CorruptMeta => f. write_str ( "corrupt meta" ) ,
40+ Error :: NotRainMetaDocument => f. write_str (
41+ "not a rain meta document: the bytes do not begin with the rain meta magic number" ,
42+ ) ,
3943 Error :: UnknownMeta => f. write_str ( "unknown meta" ) ,
4044 Error :: UnknownMagic => f. write_str ( "unknown magic" ) ,
4145 Error :: UnsupportedMeta => f. write_str ( "unsupported meta" ) ,
@@ -117,6 +121,10 @@ mod tests {
117121 #[ test]
118122 fn test_display_fixed_strings ( ) {
119123 assert_eq ! ( Error :: CorruptMeta . to_string( ) , "corrupt meta" ) ;
124+ assert_eq ! (
125+ Error :: NotRainMetaDocument . to_string( ) ,
126+ "not a rain meta document: the bytes do not begin with the rain meta magic number"
127+ ) ;
120128 assert_eq ! ( Error :: UnknownMeta . to_string( ) , "unknown meta" ) ;
121129 assert_eq ! ( Error :: UnknownMagic . to_string( ) , "unknown magic" ) ;
122130 assert_eq ! ( Error :: UnsupportedMeta . to_string( ) , "unsupported meta" ) ;
Original file line number Diff line number Diff line change 5858//! schema: None,
5959//! };
6060//!
61- //! // cbor encode the meta item
62- //! let cbor_encoded = meta_map.cbor_encode().unwrap();
61+ //! // cbor encode the meta item as a rain meta document: the document magic
62+ //! // number prefix, then the item. The decoder requires that prefix.
63+ //! let cbor_encoded = RainMetaDocumentV1Item::cbor_encode_seq(
64+ //! &vec![meta_map],
65+ //! KnownMagic::RainMetaDocumentV1,
66+ //! ).unwrap();
6367//!
64- //! // decode the data back
68+ //! // decode the document back
6569//! let cbor_decoded_vec = RainMetaDocumentV1Item::cbor_decode(&cbor_encoded).unwrap();
6670//!
6771//! // unpack the payload into AuthoringMeta
You can’t perform that action at this time.
0 commit comments