this structure is a lot better

This commit is contained in:
2022-11-27 22:30:38 +01:00
parent 489686c8ce
commit fd59f25fea
8 changed files with 44 additions and 31 deletions

View File

@ -1,10 +1,10 @@
use std::io;
use std::path::Path;
#[cfg(feature = "std")]
pub use stdmod::*;
pub use satrs_core::res_code::ResultU16;
use serde::{Deserialize, Serialize};
use serde_hex::{SerHex, StrictCapPfx};
#[derive(Debug, Copy, Clone, Serialize)]
pub struct ResultU16Info {
pub name: &'static str,
@ -55,7 +55,13 @@ impl From<ResultU16Info> for ResultU16InfoSerializable {
}
}
pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> {
#[cfg(feature = "std")]
pub mod stdmod {
use std::path::Path;
use std::io;
use super::*;
pub fn print_resultcodes_as_csv(codes: &[ResultU16Info]) -> Result<(), csv::Error> {
let mut wtr = csv::Writer::from_writer(io::stdout());
for result in codes {
wtr.serialize(ResultU16InfoSerializable::from(*result))?;
@ -76,16 +82,18 @@ pub fn write_resultcodes_to_csv(
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::fs::File;
use std::path::Path;
use std::io::{BufRead, BufReader};
// Special solution for this crate because the code generated by a macro will use
// satrs_mib::res_code::*
use crate as satrs_mib;
use satrs_core::res_code::ResultU16;
use satrs_macros::resultcode;
use satrs_mib::resultcode;
#[derive(Debug)]
#[allow(dead_code)]