summaryrefslogtreecommitdiff
path: root/src/formats/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/formats/mod.rs')
-rw-r--r--src/formats/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/formats/mod.rs b/src/formats/mod.rs
index a77bd72..105207c 100644
--- a/src/formats/mod.rs
+++ b/src/formats/mod.rs
@@ -1,8 +1,10 @@
+mod cmd;
mod inhx;
mod inhx32;
mod raw;
mod debug;
+pub use cmd::*;
pub use inhx::*;
pub use inhx32::*;
pub use raw::*;
@@ -15,6 +17,7 @@ use log::*;
#[derive(Clone, Copy, PartialEq)]
pub enum Format {
+ Cmd,
Debug,
Inhx,
Inhx32,
@@ -25,6 +28,7 @@ pub enum Format {
impl Format {
pub fn from_str(string: &str) -> Self {
match string {
+ "cmd" => Self::Cmd,
"debug" => Self::Debug,
"inhx" => Self::Inhx,
"inhx32" => Self::Inhx32,
@@ -38,6 +42,7 @@ impl Format {
impl std::fmt::Display for Format {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
let string = match self {
+ Self::Cmd => "cmd",
Self::Debug => "debug",
Self::Inhx => "inhx",
Self::Inhx32 => "inhx32",
@@ -112,6 +117,14 @@ impl InhxRecord {
}
format!(":{output}{checksum:0>2X}\n")
}
+
+ pub fn to_string_plain(self) -> String {
+ let mut output = String::new();
+ for byte in &self.bytes {
+ output.push_str(&format!("{byte:0>2X}"));
+ }
+ format!("{output}\n")
+ }
}