@@ -62,24 +62,30 @@ pub struct ClarifySliceWriter<'a> {
6262
6363/// Clarifier that creates HEX with comments
6464pub struct Clarifier {
65- // Buffer into which debug HEX and comments are written
65+ /// Buffer into which debug HEX and comments are written
6666 clarify_buf : Vec < u8 > ,
6767
68- // Position in the buffer is used to track how long is the current sub-message
68+ /// Position in the buffer is used to track how long is the current sub-message
6969 last_position : u32 ,
7070
7171 /// Used for debug indentation
7272 ///
7373 /// Pushes writer positions on the stack
7474 depth : Vec < Option < u32 > > ,
7575
76+ /// Determines if newlines and indent are currently enabled
7677 indent_enabled : bool ,
78+
79+ /// Sans-io buffer for comments
7780 comment_writer : Box < dyn CommentWriter > ,
7881}
7982
8083/// Returned by .finish()
8184pub struct ClarifyOutputs < ' a > {
85+ /// Raw DER/BER buffer
8286 pub raw : Result < Cow < ' a , [ u8 ] > > ,
87+
88+ /// Hex-encoded DER/BER with comments
8389 pub clarify_buf : Vec < u8 > ,
8490}
8591
@@ -97,13 +103,6 @@ impl<'a> ClarifyOutputs<'a> {
97103 clarify_buf : self . clarify_buf ,
98104 }
99105 }
100- // pub fn and(result: Result<Cow<'a, [u8]>>) {
101- // ClarifyOutputs {
102- // // prioritize Encode::encode errors
103- // raw: result.and(outputs.raw),
104- // clarify_buf: outputs.clarify_buf,
105- // };
106- // }
107106}
108107
109108/// Determines how comments will look like
@@ -225,17 +224,14 @@ impl Clarifier {
225224 }
226225 /// Writes string to debug output, for example a comment: `// SEQUENCE: name`
227226 pub fn write_clarify_type_str ( & mut self , start_end : & str , type_name : & str ) {
228- //let mut debugbuf = self.debug_ref.borrow_mut();
229-
230227 let comment = format ! ( "{start_end}: {type_name} " ) ;
231228 self . comment_writer . comment ( & comment) ;
232229 }
233230
234231 /// Writes string to debug output, for example a comment: `// "abc"`
235232 pub fn write_clarify_value_quote ( & mut self , type_name : & str , value : & [ u8 ] ) {
236- //let mut debugbuf = self.debug_ref.borrow_mut();
237-
238233 let contains_control = value. iter ( ) . any ( |& c| c == 0x7F || ( c < 0x20 && c != b'\n' ) ) ;
234+
239235 if value. len ( ) > 2 && !contains_control {
240236 let type_name = strip_transparent_types ( type_name) ;
241237 let comment = format ! ( "{} {:?} " , type_name, String :: from_utf8_lossy( value) ) ;
@@ -278,27 +274,13 @@ impl Clarifier {
278274 self . write_clarify_type_str ( "end" , type_name. as_ref ( ) ) ;
279275 }
280276
281- // /// for better tag-length pretty-printing inline
282- // pub fn clarify_end_tag(&mut self, _tag: &Tag) {
283- // // just to print a single length byte without indent
284- // self.indent_enabled = false;
285- // }
286-
287277 /// for better tag-length pretty-printing inline
288278 pub fn clarify_header_start_tag ( & mut self , _tag : & Tag ) {
289279 self . write_clarify_indent ( ) ;
290280 // just to print header bytes without indent
291281 self . indent_enabled = false ;
292282 }
293283
294- // fn debug_set_indent_enabled(&mut self, enabled: bool) {
295- // if !enabled {
296- // // Write tabs before we switch to in-line mode
297- // self.write_debug_indent();
298- // }
299- // self.indent_enabled = enabled;
300- // }
301-
302284 /// Writes field name, i.e. field: `public_key`
303285 ///
304286 /// when used on Sequence field:
@@ -330,15 +312,6 @@ impl Clarifier {
330312 }
331313 }
332314
333- // fn clarify_value_quote(&mut self, _type_name: &str, tag_name: &[u8]) {
334- // //self.write_debug_value_quote(type_name, tag_name);
335- // self.write_debug_value_quote("", tag_name);
336- // }
337-
338- // fn debug_int(&mut self, value: i64) {
339- // self.write_debug_int(value);
340- // }
341-
342315 /// Writes pretty-printed `CHOICE name`
343316 pub fn clarify_choice ( & mut self , choice_name : & [ u8 ] ) {
344317 self . write_clarify_indent ( ) ;
0 commit comments