File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use std:: io:: { BufWriter as IoBufWriter , Write } ;
2+
13use anyhow:: { anyhow, Result } ;
24use cbor4ii:: core:: {
35 dec:: { self , Decode , Read } ,
46 enc:: { self , Encode } ,
57 major, types,
6- utils:: BufWriter ,
78} ;
89use cid:: { multibase, Cid } ;
910use pyo3:: pybacked:: PyBackedStr ;
@@ -18,6 +19,28 @@ mod marker {
1819 pub const F64 : u8 = 0xfb ;
1920}
2021
22+ struct BufWriter < W : Write > ( IoBufWriter < W > ) ;
23+
24+ impl < W : Write > BufWriter < W > {
25+ pub fn new ( inner : W ) -> Self {
26+ BufWriter ( IoBufWriter :: new ( inner) )
27+ }
28+
29+ pub fn buffer ( & self ) -> & [ u8 ] {
30+ self . 0 . buffer ( )
31+ }
32+ }
33+
34+ impl < W : Write > enc:: Write for BufWriter < W > {
35+ type Error = std:: io:: Error ;
36+
37+ #[ inline]
38+ fn push ( & mut self , input : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
39+ self . 0 . write_all ( input) ?;
40+ Ok ( ( ) )
41+ }
42+ }
43+
2144// Based on cbor4ii/src/utils.rs.
2245/// An in-memory reader.
2346struct SliceReader < ' a > {
You can’t perform that action at this time.
0 commit comments