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

Consider "decoded" structs #34

Open
killercup opened this issue Mar 30, 2021 · 0 comments
Open

Consider "decoded" structs #34

killercup opened this issue Mar 30, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@killercup
Copy link
Member

In addition to the "lazy" and "embedded friendly" structs with getters we have now, it would be neat to add a fully parsed representation as well.

I'm imagining something like

struct MessageA { raw: [u8; 8] }

struct MessageAParsed {
  signal_1: u8,
  signal_2: f64,
}

impl DecodeCan for MessageA {
  type Output = MessageAParsed;
  fn decode(&self) -> Result<Self::Output, CanError> {
    Ok(MessageAParsed {
      signal_1: self.signal_1()?,
      signal_2: self.signal_2()?,
    })
  }
}

impl EncodeCan for MessageAParsed {
  type Output = MessageA;
  fn encode(&self) -> Result<Self::Out, CanError> {}
}

as a first step and the maybe also doing a DecodedMessage enum to go all in.

Let me know if you think this is of any use to you in practice :)

@killercup killercup added the enhancement New feature or request label Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant