this structure is a lot better
This commit is contained in:
parent
489686c8ce
commit
fd59f25fea
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -715,35 +715,34 @@ dependencies = [
|
|||||||
"csv",
|
"csv",
|
||||||
"delegate 0.8.0",
|
"delegate 0.8.0",
|
||||||
"satrs-core",
|
"satrs-core",
|
||||||
"satrs-macros",
|
|
||||||
"satrs-mib",
|
"satrs-mib",
|
||||||
"spacepackets",
|
"spacepackets",
|
||||||
"zerocopy",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "satrs-macros"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"satrs-core",
|
|
||||||
"satrs-mib",
|
|
||||||
"syn",
|
|
||||||
"trybuild",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "satrs-mib"
|
name = "satrs-mib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"csv",
|
"csv",
|
||||||
"satrs-core",
|
"satrs-core",
|
||||||
"satrs-macros",
|
"satrs-mib-codegen",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-hex",
|
"serde-hex",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "satrs-mib-codegen"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"satrs-core",
|
||||||
|
"satrs-mib",
|
||||||
|
"syn",
|
||||||
|
"trybuild",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -14,9 +14,6 @@ csv = "1"
|
|||||||
[dependencies.spacepackets]
|
[dependencies.spacepackets]
|
||||||
path = "../spacepackets"
|
path = "../spacepackets"
|
||||||
|
|
||||||
[dependencies.satrs-macros]
|
|
||||||
path = "../satrs-macros"
|
|
||||||
|
|
||||||
[dependencies.satrs-core]
|
[dependencies.satrs-core]
|
||||||
path = "../satrs-core"
|
path = "../satrs-core"
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
|
|
||||||
use satrs_core::res_code::ResultU16;
|
use satrs_mib::resultcode;
|
||||||
use satrs_macros::resultcode;
|
use satrs_mib::res_code::{ResultU16, ResultU16Info};
|
||||||
use satrs_mib::res_code::ResultU16Info;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum GroupId {
|
pub enum GroupId {
|
||||||
|
@ -7,17 +7,21 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde-hex = "0.1.0"
|
serde-hex = "0.1.0"
|
||||||
csv = "1"
|
|
||||||
|
[dependencies.csv]
|
||||||
|
version = "1"
|
||||||
|
optional = true
|
||||||
|
|
||||||
[dependencies.satrs-core]
|
[dependencies.satrs-core]
|
||||||
path = "../satrs-core"
|
path = "../satrs-core"
|
||||||
|
|
||||||
[dependencies.satrs-macros]
|
|
||||||
path = "../satrs-macros"
|
|
||||||
|
|
||||||
[dependencies.satrs-mib-codegen]
|
[dependencies.satrs-mib-codegen]
|
||||||
path = "codegen"
|
path = "codegen"
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = ["csv", "serde/std"]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Basic check which just verifies that everything compiles
|
//! Basic check which just verifies that everything compiles
|
||||||
use satrs_core::res_code::ResultU16;
|
use satrs_core::res_code::ResultU16;
|
||||||
use satrs_macros::*;
|
use satrs_mib::resultcode;
|
||||||
|
|
||||||
#[resultcode(info = "This is a test result where the first parameter is foo")]
|
#[resultcode(info = "This is a test result where the first parameter is foo")]
|
||||||
const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1);
|
const _TEST_RESULT: ResultU16 = ResultU16::const_new(0, 1);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use satrs_core::res_code::ResultU16;
|
use satrs_core::res_code::ResultU16;
|
||||||
use satrs_macros::*;
|
use satrs_mib::resultcode;
|
||||||
use satrs_mib::res_code::ResultU16Info;
|
use satrs_mib::res_code::ResultU16Info;
|
||||||
|
|
||||||
#[resultcode(info = "This is a test result where the first parameter is foo")]
|
#[resultcode(info = "This is a test result where the first parameter is foo")]
|
||||||
|
@ -1,2 +1,8 @@
|
|||||||
|
#![no_std]
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
extern crate alloc;
|
||||||
|
#[cfg(any(feature = "std", test))]
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
pub use satrs_mib_codegen::*;
|
pub use satrs_mib_codegen::*;
|
||||||
pub mod res_code;
|
pub mod res_code;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use std::io;
|
#[cfg(feature = "std")]
|
||||||
use std::path::Path;
|
pub use stdmod::*;
|
||||||
|
|
||||||
pub use satrs_core::res_code::ResultU16;
|
pub use satrs_core::res_code::ResultU16;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_hex::{SerHex, StrictCapPfx};
|
use serde_hex::{SerHex, StrictCapPfx};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Serialize)]
|
#[derive(Debug, Copy, Clone, Serialize)]
|
||||||
pub struct ResultU16Info {
|
pub struct ResultU16Info {
|
||||||
pub name: &'static str,
|
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());
|
let mut wtr = csv::Writer::from_writer(io::stdout());
|
||||||
for result in codes {
|
for result in codes {
|
||||||
wtr.serialize(ResultU16InfoSerializable::from(*result))?;
|
wtr.serialize(ResultU16InfoSerializable::from(*result))?;
|
||||||
@ -76,16 +82,18 @@ pub fn write_resultcodes_to_csv(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
use std::path::Path;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
// Special solution for this crate because the code generated by a macro will use
|
// Special solution for this crate because the code generated by a macro will use
|
||||||
// satrs_mib::res_code::*
|
// satrs_mib::res_code::*
|
||||||
use crate as satrs_mib;
|
use crate as satrs_mib;
|
||||||
use satrs_core::res_code::ResultU16;
|
use satrs_core::res_code::ResultU16;
|
||||||
use satrs_macros::resultcode;
|
use satrs_mib::resultcode;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
Loading…
Reference in New Issue
Block a user