into-a-byte 1.0.1

Build a byte from tuple of Into<u8>.
Documentation
  • Coverage
  • 50%
    2 out of 4 items documented2 out of 3 items with examples
  • Size
  • Source code size: 6.39 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 141.42 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mmmpa

into-a-byte

Build ORed byte from members of tuple of Into that acts as a bit switch.

Example

Built byte is used to send to a I2C devise for example.

use into_a_bit::*;

enum FunctionA {
    Enabled = 1 << 3,
    Disabled = 0,
}

enum FunctionB {
    Enabled = 1 << 2,
    Disabled = 0,
}

enum FunctionC {
    Enabled = 1 << 1,
    Disabled = 0,
}

enum FunctionD {
    Enabled = 1,
    Disabled = 0,
}

enums_into_u8!(FunctionA, FunctionB, FunctionC, FunctionD);

fn send_to_device(value: (FunctionA, FunctionB, FunctionC, FunctionD)) {
    // A byte for send to a register for example.
    let byte = value.into_a_byte();
    // TODO
}

fn main() {
    send_to_device((
        FunctionA::Enabled,
        FunctionB::Disabled,
        FunctionC::Enabled,
        FunctionD::Enabled,
    ));
}