bc_ur/
multipart_encoder.rs

1use crate::{Result, UR};
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 { self.encoder.current_index() }
23
24    pub fn parts_count(&self) -> usize { self.encoder.fragment_count() }
25}