Skip to content

Commit

Permalink
Merge pull request #230 from TheNeikos/feature/add_no_std
Browse files Browse the repository at this point in the history
Feature/add no std
  • Loading branch information
TheNeikos authored Mar 20, 2024
2 parents 50307b8 + f4d72be commit 1d517be
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mqtt-format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//

#![cfg_attr(all(feature = "mqttv5", not(feature = "mqttv3"), not(test)), no_std)]
#![deny(clippy::disallowed_methods)]
#![deny(clippy::disallowed_types)]

Expand Down
2 changes: 2 additions & 0 deletions mqtt-format/src/v5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//

#![deny(missing_debug_implementations)]
#![deny(clippy::std_instead_of_core)]
#![deny(clippy::alloc_instead_of_core)]

pub mod bytes;
pub mod fixed_header;
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/suback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'i> MSuback<'i> {

// SAFETY: We verified above that the payload slice only contains valid SubackReasonCode
// bytes
let reasons: &[SubackReasonCode] = unsafe { std::mem::transmute(payload) };
let reasons: &[SubackReasonCode] = unsafe { core::mem::transmute(payload) };

Ok(Self {
packet_identifier,
Expand Down
4 changes: 2 additions & 2 deletions mqtt-format/src/v5/packets/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ pub struct Subscriptions<'i> {
start: &'i [u8],
}

impl<'i> std::fmt::Debug for Subscriptions<'i> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl<'i> core::fmt::Debug for Subscriptions<'i> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Subscriptions").finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/packets/unsuback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'i> MUnsuback<'i> {

// SAFETY: We verified above that the payload slice only contains valid UnsubackReasonCode
// bytes
let reasons: &[UnsubackReasonCode] = unsafe { std::mem::transmute(payload) };
let reasons: &[UnsubackReasonCode] = unsafe { core::mem::transmute(payload) };

Ok(Self {
packet_identifier,
Expand Down
4 changes: 2 additions & 2 deletions mqtt-format/src/v5/packets/unsubscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub struct Unsubscriptions<'i> {
start: &'i [u8],
}

impl<'i> std::fmt::Debug for Unsubscriptions<'i> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl<'i> core::fmt::Debug for Unsubscriptions<'i> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Unsubscriptions").finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro_rules! define_properties {
$( $((anker: $prop_anker:literal ))? $prop_name:ident : $prop:ty),* $(,)?
}) => {
$(
#[doc = std::concat!("Properties helper type for the [", std::stringify!($packettypename), "] type.")]
#[doc = core::concat!("Properties helper type for the [", core::stringify!($packettypename), "] type.")]
#[doc = ""] // newline
)?
$(
Expand Down
2 changes: 1 addition & 1 deletion mqtt-format/src/v5/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn parse_string<'i>(input: &mut &'i Bytes) -> MResult<&'i str> {
winnow::combinator::trace("mqtt_string", |input: &mut &'i Bytes| {
let maybe_str = length_take(parse_u16).parse_next(input)?;

std::str::from_utf8(maybe_str)
core::str::from_utf8(maybe_str)
.map_err(|e| ErrMode::from_external_error(input, winnow::error::ErrorKind::Verify, e))
})
.parse_next(input)
Expand Down
4 changes: 2 additions & 2 deletions mqtt-format/src/v5/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

macro_rules! speclink {
($anker:literal) => {
std::concat!(
core::concat!(
"https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#",
$anker
)
Expand All @@ -16,7 +16,7 @@ pub(crate) use speclink;

macro_rules! md_speclink {
($anker:literal) => {
std::concat!(
core::concat!(
"[📖 Specification](",
$crate::v5::util::speclink!($anker),
")"
Expand Down
4 changes: 2 additions & 2 deletions mqtt-format/src/v5/variable_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ define_properties! {[

pub struct UserProperties<'i>(pub &'i [u8]);

impl<'i> std::fmt::Debug for UserProperties<'i> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl<'i> core::fmt::Debug for UserProperties<'i> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("UserProperties").finish()
}
}
Expand Down

0 comments on commit 1d517be

Please sign in to comment.