refactor: remove custom endian traits in favor of standard library
This commit is contained in:
2 files changed
-33
No files matched your search
@@ -1,32 +0,0 @@
|
|||||||
pub trait ToNativeEndian {
|
|
||||||
fn to_ne(self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple trait that adds a function to u32/u64 types
|
|
||||||
* to convert a number's endianness to native-endian
|
|
||||||
* based on the platform the code was built for
|
|
||||||
*/
|
|
||||||
impl ToNativeEndian for u32 {
|
|
||||||
#[cfg(target_endian = "big")]
|
|
||||||
fn to_ne(self) -> Self {
|
|
||||||
self.to_be()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_endian = "little")]
|
|
||||||
fn to_ne(self) -> Self {
|
|
||||||
self.to_le()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToNativeEndian for u64 {
|
|
||||||
#[cfg(target_endian = "big")]
|
|
||||||
fn to_ne(self) -> Self {
|
|
||||||
self.to_be()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_endian = "little")]
|
|
||||||
fn to_ne(self) -> Self {
|
|
||||||
self.to_le()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ extern crate core;
|
|||||||
|
|
||||||
mod baseliner;
|
mod baseliner;
|
||||||
mod config;
|
mod config;
|
||||||
mod endian;
|
|
||||||
mod log;
|
mod log;
|
||||||
mod netlink;
|
mod netlink;
|
||||||
mod pinger;
|
mod pinger;
|
||||||
|
|||||||
Reference in new issue
Block a user