chore: Reorganize file tree for easier onboarding. Rust project now at the root for simple git clone && cargo run
This commit is contained in:
6
harmony_types/Cargo.toml
Normal file
6
harmony_types/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "harmony_types"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
26
harmony_types/src/lib.rs
Normal file
26
harmony_types/src/lib.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
pub mod net {
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct MacAddress(pub [u8; 6]);
|
||||
|
||||
impl MacAddress {
|
||||
#[cfg(test)]
|
||||
pub fn dummy() -> Self {
|
||||
Self([0, 0, 0, 0, 0, 0])
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&MacAddress> for String {
|
||||
fn from(value: &MacAddress) -> Self {
|
||||
format!(
|
||||
"{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
value.0[0], value.0[1], value.0[2], value.0[3], value.0[4], value.0[5]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for MacAddress {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!("MacAddress {}", String::from(self)))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user