-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remove DynamicOneShot
trait.
#19
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
//! ADC input channels | ||
use crate::{ic, Ads1x1x, BitFlags as BF, Config}; | ||
|
||
mod private { | ||
pub trait Sealed {} | ||
} | ||
use private::ChannelSelection; | ||
|
||
/// Marker type for an ADC input channel. | ||
pub trait ChannelId<T>: private::Sealed { | ||
pub trait ChannelId<T> { | ||
/// Get the channel. | ||
fn channel_id() -> ChannelSelection; | ||
} | ||
|
||
macro_rules! impl_channels { | ||
($(#[doc = $doc:expr] $CH:ident => [$($IC:ident),+]),+ $(,)?) => { | ||
#[derive(Debug, Clone, Copy)] | ||
/// ADC input channel selection. | ||
pub enum ChannelSelection { | ||
$( | ||
#[doc = $doc] | ||
$CH, | ||
)+ | ||
mod private { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you move this module inside this macro?
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This way the |
||
#[derive(Debug, Clone, Copy)] | ||
/// ADC input channel selection. | ||
pub enum ChannelSelection { | ||
$( | ||
#[doc = $doc] | ||
$CH, | ||
)+ | ||
} | ||
} | ||
|
||
$( | ||
#[doc = $doc] | ||
pub struct $CH; | ||
|
||
impl private::Sealed for $CH {} | ||
|
||
$( | ||
impl<I2C, CONV, MODE> ChannelId<Ads1x1x<I2C, ic::$IC, CONV, MODE>> for $CH { | ||
fn channel_id() -> ChannelSelection { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,7 +213,7 @@ impl BitFlags { | |
} | ||
|
||
pub mod channel; | ||
pub use channel::{ChannelId, ChannelSelection}; | ||
pub use channel::ChannelId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think we should expose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't. |
||
mod construction; | ||
mod conversion; | ||
pub use crate::conversion::{ConvertMeasurement, ConvertThreshold}; | ||
|
@@ -224,8 +224,7 @@ mod types; | |
use crate::types::Config; | ||
pub use crate::types::{ | ||
mode, Ads1x1x, ComparatorLatching, ComparatorMode, ComparatorPolarity, ComparatorQueue, | ||
DataRate12Bit, DataRate16Bit, DynamicOneShot, Error, FullScaleRange, ModeChangeError, | ||
SlaveAddr, | ||
DataRate12Bit, DataRate16Bit, Error, FullScaleRange, ModeChangeError, SlaveAddr, | ||
}; | ||
|
||
mod private { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should this trait not be sealed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually sealed since the
ChannelSelection
type is private.