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()
15 .annotate(true)
16 .tags(TagsStoreOpt::Custom(context.tags())),
17 )
18 })
19 }
20
21 /// Returns the CBOR diagnostic notation for this envelope.
22 ///
23 /// Uses the current format context.
24 ///
25 /// See [RFC-8949 §8](https://www.rfc-editor.org/rfc/rfc8949.html#name-diagnostic-notation)
26 /// for information on CBOR diagnostic notation.
27 pub fn diagnostic(&self) -> String { self.tagged_cbor().diagnostic() }
28}