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

input-output-hk / catalyst-libs / 16643956608

31 Jul 2025 08:28AM UTC coverage: 67.359% (+3.8%) from 63.544%
16643956608

Pull #338

github

web-flow
Merge 365ec321b into 015484150
Pull Request #338: feat(rust/signed-doc): Implement new Catalyst Signed Doc

2453 of 2675 new or added lines in 38 files covered. (91.7%)

19 existing lines in 7 files now uncovered.

11315 of 16798 relevant lines covered (67.36%)

2474.44 hits per line

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

89.29
/rust/signed_doc/src/content.rs
1
//! Catalyst Signed Document Content Payload
2

3
/// Document Content bytes (COSE payload).
4
#[derive(Debug, Clone, PartialEq, Default)]
5
pub struct Content(Vec<u8>);
6

7
impl Content {
8
    /// Return content bytes.
9
    #[must_use]
10
    pub fn bytes(&self) -> &[u8] {
80✔
11
        self.0.as_slice()
80✔
12
    }
80✔
13

14
    /// Return content byte size.
15
    #[must_use]
NEW
16
    pub fn size(&self) -> usize {
×
NEW
17
        self.0.len()
×
UNCOV
18
    }
×
19
}
20

21
impl From<Vec<u8>> for Content {
22
    fn from(value: Vec<u8>) -> Self {
56✔
23
        Self(value)
56✔
24
    }
56✔
25
}
26

27
impl minicbor::Encode<()> for Content {
28
    fn encode<W: minicbor::encode::Write>(
151✔
29
        &self, e: &mut minicbor::Encoder<W>, _ctx: &mut (),
151✔
30
    ) -> Result<(), minicbor::encode::Error<W::Error>> {
151✔
31
        if self.0.is_empty() {
151✔
32
            e.null()?;
95✔
33
        } else {
34
            e.bytes(self.0.as_slice())?;
56✔
35
        }
36
        Ok(())
151✔
37
    }
151✔
38
}
39

40
impl minicbor::Decode<'_, ()> for Content {
41
    fn decode(
204✔
42
        d: &mut minicbor::Decoder<'_>, _ctx: &mut (),
204✔
43
    ) -> Result<Self, minicbor::decode::Error> {
204✔
44
        let p = d.position();
204✔
45
        d.null()
204✔
46
            .map(|()| Self(Vec::new()))
204✔
47
            // important to use `or_else` so it will lazy evaluated at the time when it is needed
48
            .or_else(|_| {
204✔
49
                d.set_position(p);
108✔
50
                d.bytes().map(Vec::from).map(Self)
108✔
51
            })
108✔
52
    }
204✔
53
}
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