• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / catalyst-libs / 16648343345

31 Jul 2025 11:59AM UTC coverage: 66.061% (-1.3%) from 67.341%
16648343345

push

github

web-flow
feat(general): `rbac-registration` version `0.0.6` (#452)

* bump rbac-registration version

* fix

11097 of 16798 relevant lines covered (66.06%)

2374.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.63
/rust/cbork-utils/src/decode_context.rs
1
//! CBOR decode context which could used as an argument for the `minicbor::Decode` logic
2

3
/// a type alias for the deterministic error handler function
4
pub type DeterministicErrorHandler =
5
    Box<dyn FnMut(minicbor::decode::Error) -> Result<(), minicbor::decode::Error>>;
6

7
/// CBOR `minicbor::Decode` context struct.
8
pub enum DecodeCtx {
9
    /// Decode a CBOR object applying deterministic decoding rules (RFC 8949
10
    /// Section 4.2).
11
    Deterministic,
12
    /// Decode a CBOR object **NOT** applying deterministic decoding rules (RFC 8949
13
    /// Section 4.2).
14
    ///
15
    /// Optionally it could carry an deterministic decoding error handler, so if provided
16
    /// deterministic decoding rule is applied and the error message passed to the
17
    /// handler function
18
    NonDeterministic(Option<DeterministicErrorHandler>),
19
}
20

21
impl DecodeCtx {
22
    /// Returns `DecodeCtx::NonDeterministic` variant
23
    /// Decode a CBOR object **NOT** applying deterministic decoding rules (RFC 8949
24
    /// Section 4.2).
25
    #[must_use]
26
    pub fn non_deterministic() -> Self {
5✔
27
        Self::NonDeterministic(None)
5✔
28
    }
5✔
29

30
    /// Returns `DecodeCtx::NonDeterministic` variant
31
    /// Decode a CBOR object **NOT** applying deterministic decoding rules (RFC 8949
32
    /// Section 4.2).
33
    ///
34
    /// When deterministic decoding rule is applied, the error message passed to
35
    /// the provided `handler`
36
    #[must_use]
37
    pub fn non_deterministic_with_handler(
×
38
        handler: impl FnMut(minicbor::decode::Error) -> Result<(), minicbor::decode::Error> + 'static,
×
39
    ) -> Self {
×
40
        Self::NonDeterministic(Some(Box::new(handler)))
×
41
    }
×
42

43
    /// Depends on the set `DecodeCtx` variant applies the provided deterministic
44
    /// validation
45
    pub(crate) fn try_check(
53✔
46
        &mut self, f: impl FnOnce() -> Result<(), minicbor::decode::Error>,
53✔
47
    ) -> Result<(), minicbor::decode::Error> {
53✔
48
        match self {
12✔
49
            Self::Deterministic => f(),
41✔
50
            Self::NonDeterministic(None) => Ok(()),
12✔
51
            Self::NonDeterministic(Some(h)) => {
×
52
                if let Err(err) = f() {
×
53
                    h(err)
×
54
                } else {
55
                    Ok(())
×
56
                }
57
            },
58
        }
59
    }
53✔
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc