use std::io::{Write, Seek};
trait WriteSeek: Write + Seek {}
impl<T: Write + Seek> WriteSeek for T {}
use std::collections::HashMap;
use crate::blocks::channel_block::ChannelBlock;
use crate::error::MdfError;
use crate::writer::mdf_writer::data::ChannelEncoder;
mod io;
mod init;
pub mod data;
mod vlsd;
struct OpenDataBlock {
dg_id: String,
dt_id: String,
start_pos: u64,
record_size: usize,
record_count: u64,
total_record_count: u64,
channels: Vec<ChannelBlock>,
dt_ids: Vec<String>,
dt_positions: Vec<u64>,
dt_sizes: Vec<u64>,
record_buf: Vec<u8>,
record_template: Vec<u8>,
encoders: Vec<ChannelEncoder>,
vlsd_payloads: Vec<Option<Vec<u8>>>,
vlsd_channel_ids: Vec<Option<String>>,
}
pub struct MdfWriter {
file: Box<dyn WriteSeek>,
offset: u64,
block_positions: HashMap<String, u64>,
open_dts: HashMap<String, OpenDataBlock>,
sd_buffers: HashMap<String, Vec<u8>>,
dt_counter: usize,
last_dg: Option<String>,
cg_to_dg: HashMap<String, String>,
cg_offsets: HashMap<String, usize>,
cg_channels: HashMap<String, Vec<ChannelBlock>>,
cg_channel_ids: HashMap<String, Vec<String>>,
channel_map: HashMap<String, (String, usize)>,
cg_inval_bytes: HashMap<String, u32>,
}