use crate::netlist::traits::{NetlistBase, NetlistEdit};
use std::io::{Read, Write};
pub trait NetlistReader {
type Error;
fn read_into_netlist<R: Read, N: NetlistEdit>(
&self,
reader: &mut R,
netlist: &mut N,
) -> Result<(), Self::Error>;
fn read_netlist<R: Read, N: NetlistEdit + Default>(
&self,
reader: &mut R,
) -> Result<N, Self::Error> {
let mut netlist = N::default();
self.read_into_netlist(reader, &mut netlist)?;
Ok(netlist)
}
}
pub trait NetlistWriter {
type Error;
fn write_netlist<W: Write, N: NetlistBase>(
&self,
writer: &mut W,
netlist: &N,
) -> Result<(), Self::Error>;
}