noodles_cram/container/
block_content_encoder_map.rs1mod builder;
4
5pub use self::builder::Builder;
6
7use std::collections::HashMap;
8
9use crate::{codecs::Encoder, container::block};
10
11#[derive(Clone, Debug)]
13pub struct BlockContentEncoderMap {
14 core_data_encoder: Option<Encoder>,
15 data_series_encoders: Vec<Option<Encoder>>,
16 tag_values_encoders: HashMap<block::ContentId, Option<Encoder>>,
17}
18
19impl BlockContentEncoderMap {
20 pub fn builder() -> Builder {
29 Builder::default()
30 }
31
32 pub(crate) fn core_data_encoder(&self) -> Option<&Encoder> {
33 self.core_data_encoder.as_ref()
34 }
35
36 pub(crate) fn data_series_encoders(&self) -> &[Option<Encoder>] {
37 &self.data_series_encoders
38 }
39
40 pub(crate) fn get_data_series_encoder(
41 &self,
42 block_content_id: block::ContentId,
43 ) -> Option<Option<&Encoder>> {
44 let i = (block_content_id as usize) - 1;
45 self.data_series_encoders.get(i).map(|e| e.as_ref())
46 }
47
48 pub(crate) fn tag_values_encoders(&self) -> &HashMap<block::ContentId, Option<Encoder>> {
49 &self.tag_values_encoders
50 }
51
52 pub(crate) fn get_tag_values_encoders(
53 &self,
54 block_content_id: block::ContentId,
55 ) -> Option<Option<&Encoder>> {
56 self.tag_values_encoders
57 .get(&block_content_id)
58 .map(|e| e.as_ref())
59 }
60}
61
62impl Default for BlockContentEncoderMap {
63 fn default() -> Self {
64 Self::builder().build()
65 }
66}