Trait atsamd_hal::gpio::pin::AnyPin

source ·
pub trait AnyPinwhere
    Self: Sealed + From<SpecificPin<Self>> + Into<SpecificPin<Self>> + AsRef<SpecificPin<Self>> + AsMut<SpecificPin<Self>>,{
    type Id: PinId;
    type Mode: PinMode;
}
Expand description

Type class for Pin types

This trait uses the AnyKind trait pattern to create a type class for Pin types. See the AnyKind documentation for more details on the pattern.

v1 Compatibility

Normally, this trait would use Is<Type = SpecificPin<Self>> as a super trait. But doing so would restrict implementations to only the v2 Pin type in this module. To aid in backwards compatibility, we want to implement AnyPin for the v1 Pin type as well. This is possible for a few reasons. First, both structs are zero-sized, so there is no meaningful memory layout to begin with. And even if there were, the v1 Pin type is a newtype wrapper around a v2 Pin, and single-field structs are guaranteed to have the same layout as the field, even for repr(Rust).

Required Associated Types§

source

type Id: PinId

PinId of the corresponding Pin

source

type Mode: PinMode

PinMode of the corresponding Pin

Implementors§

source§

impl<I, M> AnyPin for Pin<I, M>where I: PinId, M: PinMode,

§

type Id = I

§

type Mode = M