bc_ur/
multipart_encoder.rs1use crate::{ UR, Result };
2
3pub struct MultipartEncoder<'a> {
4 encoder: ur::Encoder<'a>,
5}
6
7impl<'a> MultipartEncoder<'a> {
8 pub fn new(ur: &'a UR, max_fragment_len: usize) -> Result<Self> {
9 Ok(Self {
10 encoder: ur::Encoder::new(
11 &ur.cbor().to_cbor_data(),
12 max_fragment_len,
13 ur.ur_type_str()
14 )?,
15 })
16 }
17
18 pub fn next_part(&mut self) -> Result<String> {
19 Ok(self.encoder.next_part()?)
20 }
21
22 pub fn current_index(&self) -> usize {
23 self.encoder.current_index()
24 }
25
26 pub fn parts_count(&self) -> usize {
27 self.encoder.fragment_count()
28 }
29}