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

Implement Channel<Adc> for DynPin #557

Closed
wants to merge 4 commits into from
Closed

Conversation

jannic
Copy link
Member

@jannic jannic commented Mar 3, 2023

No description provided.

@jannic jannic mentioned this pull request Mar 3, 2023
@jannic jannic marked this pull request as ready for review March 5, 2023 16:55
where
WORD: From<u16>,
{
type Error = ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have an enum there?

Something simple like

#[cfg_attr(feature = "defmt", derive(defmt::Defmt))]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct InvalidPinError;

and return Err(nb::Error::Other(InvalidPinError)).

(The exact error's name may be different.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I copied that type from impl<WORD, PIN> OneShot<Adc, WORD, PIN> for Adc. But there, something like InvalidPinError can't happen. In fact, that implementation never returns Err. I wonder why it has type Error = () and not type Error = Infallible. But that's a different topic, and changing that would be a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include all those derives on purpose:

  • we don't do it on the other error types in this crate
  • I think we should strive for consistently
  • adding derives is easier than removing them, as it doesn't break existing code

@jannic jannic marked this pull request as draft May 5, 2023 21:27
@jannic
Copy link
Member Author

jannic commented May 5, 2023

Changed to draft as it probably conflicts with #585

@jannic
Copy link
Member Author

jannic commented Jul 22, 2023

Obsoleted by #585

@jannic jannic closed this Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants