-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from thvdveld/dot15d4-frame
Move frame logic in own crate
- Loading branch information
Showing
30 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
use clap::Parser; | ||
use colored::*; | ||
use dot15d4::frame::*; | ||
use dot15d4_frame::*; | ||
|
||
struct Writer { | ||
indent: usize, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "dot15d4-frame" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
dot15d4-macros = { path = "../dot15d4-macros" } | ||
|
||
bitflags = "2.4.2" | ||
heapless = "0.8.0" | ||
|
||
arbitrary = { version = "1.3.2", features = ["derive"], optional = true } | ||
|
||
[dev-dependencies] | ||
env_logger = "0.11.3" | ||
log = "0.4.21" | ||
|
||
[features] | ||
std = [] | ||
fuzz = ["arbitrary"] |
2 changes: 1 addition & 1 deletion
2
dot15d4/examples/parsing.rs → dot15d4-frame/examples/parsing.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use dot15d4::frame::*; | ||
use dot15d4_frame::*; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
dot15d4/src/frame/ie/headers.rs → dot15d4-frame/src/ie/headers.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
dot15d4/src/frame/repr/builder.rs → dot15d4-frame/src/repr/builder.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
//! Time structures. | ||
//! | ||
//! - [`Instant`] is used to represent a point in time. | ||
//! - [`Duration`] is used to represent a duration of time. | ||
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)] | ||
#[cfg_attr(feature = "fuzz", derive(arbitrary::Arbitrary))] | ||
pub struct Instant { | ||
us: i64, | ||
} | ||
|
||
impl Instant { | ||
pub const fn from_us(us: i64) -> Self { | ||
Self { us } | ||
} | ||
|
||
pub const fn as_us(&self) -> i64 { | ||
self.us | ||
} | ||
} | ||
|
||
impl core::fmt::Display for Instant { | ||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
write!(f, "{:.2}ms", self.as_us() as f32 / 1000.0) | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)] | ||
#[cfg_attr(feature = "fuzz", derive(arbitrary::Arbitrary))] | ||
pub struct Duration(i64); | ||
|
||
impl Duration { | ||
pub const fn from_us(us: i64) -> Self { | ||
Self(us) | ||
} | ||
|
||
pub const fn as_us(&self) -> i64 { | ||
self.0 | ||
} | ||
} | ||
|
||
impl core::fmt::Display for Duration { | ||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
write!(f, "{:.2}ms", self.as_us() as f32 / 1000.0) | ||
} | ||
} | ||
|
||
impl core::ops::Sub for Instant { | ||
type Output = Self; | ||
|
||
fn sub(self, rhs: Instant) -> Self::Output { | ||
Self::from_us(self.as_us() - rhs.as_us()) | ||
} | ||
} | ||
|
||
impl core::ops::Sub<Duration> for Instant { | ||
type Output = Self; | ||
|
||
fn sub(self, rhs: Duration) -> Self::Output { | ||
Self::from_us(self.us - rhs.as_us()) | ||
} | ||
} | ||
|
||
impl core::ops::Sub for Duration { | ||
type Output = Self; | ||
|
||
fn sub(self, rhs: Duration) -> Self::Output { | ||
Self::from_us(self.as_us() - rhs.as_us()) | ||
} | ||
} | ||
|
||
impl core::ops::Mul<usize> for Duration { | ||
type Output = Self; | ||
|
||
fn mul(self, rhs: usize) -> Self::Output { | ||
Self::from_us(self.as_us() * rhs as i64) | ||
} | ||
} | ||
|
||
impl core::ops::Add<Duration> for Instant { | ||
type Output = Self; | ||
|
||
fn add(self, rhs: Duration) -> Self::Output { | ||
Self::from_us(self.us + rhs.as_us()) | ||
} | ||
} | ||
|
||
impl core::ops::Div<usize> for Duration { | ||
type Output = Self; | ||
|
||
fn div(self, rhs: usize) -> Self::Output { | ||
Self::from_us(self.as_us() / rhs as i64) | ||
} | ||
} | ||
|
||
impl core::ops::Add<Duration> for Duration { | ||
type Output = Self; | ||
|
||
fn add(self, rhs: Duration) -> Self::Output { | ||
Self::from_us(self.as_us() + rhs.as_us()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters