bc_envelope/format/diagnostic.rs
1use dcbor::prelude::*;
2
3use crate::{Envelope, FormatContext, with_format_context};
4
5impl Envelope {
6 /// Returns the CBOR diagnostic notation for this envelope, with
7 /// annotations.
8 ///
9 /// See [RFC-8949 §8](https://www.rfc-editor.org/rfc/rfc8949.html#name-diagnostic-notation)
10 /// for information on CBOR diagnostic notation.
11 pub fn diagnostic_annotated(&self) -> String {
12 with_format_context!(|context: &FormatContext| {
13 self.tagged_cbor().diagnostic_opt(
14 &DiagFormatOpts::default().annotate(true).tags(TagsStoreOpt::Custom(context.tags())),
15 )
16 })
17 }
18
19 /// Returns the CBOR diagnostic notation for this envelope.
20 ///
21 /// Uses the current format context.
22 ///
23 /// See [RFC-8949 §8](https://www.rfc-editor.org/rfc/rfc8949.html#name-diagnostic-notation)
24 /// for information on CBOR diagnostic notation.
25 pub fn diagnostic(&self) -> String { self.tagged_cbor().diagnostic() }
26}