fmt: make all macros macro_rules
so scoping is consistent.
This commit is contained in:
@ -4,7 +4,6 @@ use smoltcp::time::Instant;
|
||||
|
||||
use super::*;
|
||||
use crate::device::LinkState;
|
||||
use crate::fmt::*;
|
||||
use crate::{Interface, SocketSet};
|
||||
|
||||
pub struct DhcpConfigurator {
|
||||
|
@ -2,7 +2,6 @@ use heapless::Vec;
|
||||
use smoltcp::time::Instant;
|
||||
use smoltcp::wire::{Ipv4Address, Ipv4Cidr};
|
||||
|
||||
use crate::fmt::*;
|
||||
use crate::{Interface, SocketSet};
|
||||
|
||||
mod statik;
|
||||
|
@ -1,7 +1,6 @@
|
||||
use smoltcp::time::Instant;
|
||||
|
||||
use super::*;
|
||||
use crate::fmt::*;
|
||||
use crate::{Interface, SocketSet};
|
||||
|
||||
pub struct StaticConfigurator {
|
||||
|
@ -3,7 +3,6 @@ use smoltcp::phy::Device as SmolDevice;
|
||||
use smoltcp::phy::DeviceCapabilities;
|
||||
use smoltcp::time::Instant as SmolInstant;
|
||||
|
||||
use crate::fmt::*;
|
||||
use crate::packet_pool::PacketBoxExt;
|
||||
use crate::Result;
|
||||
use crate::{Packet, PacketBox, PacketBuf};
|
||||
|
@ -1,74 +1,171 @@
|
||||
#![macro_use]
|
||||
#![allow(unused_macros)]
|
||||
|
||||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
pub use fmt::*;
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::assert!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::assert!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::assert_eq!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::assert_eq!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::assert_ne!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::assert_ne!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::debug_assert!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug_assert!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::debug_assert_eq!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug_assert_eq!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::debug_assert_ne!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug_assert_ne!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::todo!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::todo!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
core::panic!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::panic!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! trace {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::trace!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::trace!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! debug {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(fevature = "log")]
|
||||
log::debug!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::debug!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! info {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::info!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::info!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! warn {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::warn!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::warn!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! error {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
#[cfg(feature = "log")]
|
||||
log::error!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
defmt::error!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
mod fmt {
|
||||
pub use defmt::{
|
||||
assert, assert_eq, assert_ne, debug, debug_assert, debug_assert_eq, debug_assert_ne, error,
|
||||
info, panic, todo, trace, unreachable, unwrap, warn,
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
defmt::unwrap!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "log")]
|
||||
mod fmt {
|
||||
pub use core::{
|
||||
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo,
|
||||
unreachable,
|
||||
};
|
||||
pub use log::{debug, error, info, trace, warn};
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "defmt", feature = "log")))]
|
||||
mod fmt {
|
||||
#![macro_use]
|
||||
|
||||
pub use core::{
|
||||
assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, panic, todo,
|
||||
unreachable,
|
||||
};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! trace {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
($($msg:expr),+ $(,)?) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[macro_export]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
@ -20,7 +20,6 @@ use smoltcp::wire::{IpAddress, IpCidr, Ipv4Address, Ipv4Cidr};
|
||||
use crate::config::Configurator;
|
||||
use crate::config::Event;
|
||||
use crate::device::{Device, DeviceAdapter, LinkState};
|
||||
use crate::fmt::*;
|
||||
use crate::{Interface, SocketSet};
|
||||
|
||||
const ADDRESSES_LEN: usize = 1;
|
||||
|
@ -11,7 +11,6 @@ use smoltcp::time::Duration;
|
||||
use smoltcp::wire::IpEndpoint;
|
||||
|
||||
use super::stack::Stack;
|
||||
use crate::fmt::*;
|
||||
use crate::{Error, Result};
|
||||
|
||||
pub struct TcpSocket<'a> {
|
||||
|
Reference in New Issue
Block a user