Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bincode::Encode seems to fail pretty hard and tries to modify the doc comment #427

Closed
haata opened this issue Oct 26, 2021 · 3 comments
Closed

Comments

@haata
Copy link

haata commented Oct 26, 2021

bincode-2.0.0-alpha.0

/// HID-IO Packet Buffer Struct
///
/// # Remarks
/// Used to store HID-IO data chunks. Will be chunked into individual packets on transmission.
#[repr(C)]
#[derive(PartialEq, Clone, Debug, bincode::Encode)]
#[cfg_attr(feature = "defmt-impl", derive(defmt::Format))]
pub struct HidIoPacketBuffer<const H: usize> {
    /// Type of packet (Continued is automatically set if needed)
    pub ptype: HidIoPacketType,
    /// Packet Id
    pub id: HidIoCommandId,
    /// Packet length for serialization (in bytes)
    pub max_len: u32,
    /// Payload data, chunking is done automatically by serializer
    pub data: Vec<u8, H>,
    /// Set False if buffer is not complete, True if it is
    pub done: bool,
}
error: Invalid rust syntax
   --> hid-io-protocol/src/lib.rs:158:1
    |
158 | ///
    | ^^^

Some notes:

  • Embedded target, no alloc, no_std
  • All features disabled, except for derive
  • Vec is actually a heapless::Vec
  • Same problem if I try it on a simple enum
  • defmt::Format is a serialized logging format for embedded targets used for debugging
#[repr(u32)]
#[derive(PartialEq, Clone, Copy, Debug, IntoPrimitive, TryFromPrimitive, bincode::Encode)]
#[cfg_attr(feature = "defmt-impl", derive(defmt::Format))]
/// Requests for to perform a specific action
pub enum HidIoCommandId {
    SupportedIds = 0x00,
    GetInfo = 0x01,
    TestPacket = 0x02,
    ResetHidIo = 0x03,
    Reserved = 0x04, // ... 0x0F

    GetProperties = 0x10,
    KeyState = 0x11,
    KeyboardLayout = 0x12,
    KeyLayout = 0x13,
    KeyShapes = 0x14,
    LedLayout = 0x15,
    FlashMode = 0x16,
    UnicodeText = 0x17,
    UnicodeState = 0x18,
    HostMacro = 0x19,
    SleepMode = 0x1A,

    KllState = 0x20,
    PixelSetting = 0x21,
    PixelSet1c8b = 0x22,
    PixelSet3c8b = 0x23,
    PixelSet1c16b = 0x24,
    PixelSet3c16b = 0x25,

    OpenUrl = 0x30,
    TerminalCmd = 0x31,
    GetInputLayout = 0x32,
    SetInputLayout = 0x33,
    TerminalOut = 0x34,

    HidKeyboard = 0x40,
    HidKeyboardLed = 0x41,
    HidMouse = 0x42,
    HidJoystick = 0x43,
    HidSystemCtrl = 0x44,
    HidConsumerCtrl = 0x45,

    ManufacturingTest = 0x50,
    ManufacturingResult = 0x51,

    Unused = 0xFFFF,
}
error: Invalid rust syntax
  --> hid-io-protocol/src/lib.rs:85:1
   |
85 | /// Requests for to perform a specific action
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@VictorKoenders
Copy link
Contributor

Going to assume this is fixed in #428, if not feel free to re-open this. If you find any more issues feel free to open more issues

@haata
Copy link
Author

haata commented Nov 7, 2021

👍 Yeah so far so good with most of the compilation issues. I'll need to wait for #422 before I can fully finish my port from bincode-core.

@VictorKoenders
Copy link
Contributor

Note that bincode's derive macro currently does not work with fields that only implement serde's traits. The tracking issue for this is #433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants