Git Product home page Git Product logo

Comments (4)

sharksforarms avatar sharksforarms commented on August 20, 2024 1

I'm thinking the naming skip could be used for something else, for example:

struct SomeStruct {
    #[deku(bits = "6")]
    field_a: u8,

    #[deku(skip, map = "to_string(field_a)" )]
    field_a_as_string: String,

    field_b: u8,
}

If a user really wanted to "skip", the user could specify a custom reader/writer, would that be sufficient? These types of utility functions could be provided by deku, i.e.

struct SomeStruct {
    #[deku(bits = "6")]
    field_a: u8,

    #[deku(reader = "deku::utils::skip_x_bits(2)", writer = "")]
    _unused: u8,

    field_b: u8,
}

from deku.

sharksforarms avatar sharksforarms commented on August 20, 2024

Alternatively, ignore might be a good name

struct SomeStruct {
    #[deku(bits = "6")]
    field_a: u8,

    #[deku(ignore, bits = "2")]
    _unused: u8,

    field_b: u8,
}

from deku.

wcampbell0x2a avatar wcampbell0x2a commented on August 20, 2024

Would this be possible?

struct SomeStruct {
    #[deku(bits = "6")]
    field_a: u8,
    #[deku(ignore, bits = "2")]
    field_b: u8,
}

Where 6 bits are read, then 2 are ignored, then 8 are read for u8. Without a dummy struct field.

from deku.

sharksforarms avatar sharksforarms commented on August 20, 2024

Would this be possible?

struct SomeStruct {
    #[deku(bits = "6")]
    field_a: u8,
    #[deku(ignore, bits = "2")]
    field_b: u8,
}

Where 6 bits are read, then 2 are ignored, then 8 are read for u8. Without a dummy struct field.

@wcampbell0x2a, it may be possible yes. It is required to have a field though. Just to expand on the example, something like this could be interesting, not sure if they're combined or not... needs experimentation

struct SomeStruct {
    #[deku(bits = "6")]
    field_a: u8,
    #[deku(ignore, bits = "2")]
    #[deku(bits = "6")]
    field_b: u8,
}

from deku.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.