pub trait UsesPin {
// Required method
fn using<OP: Into<OwnOrBorrow<'static, dyn Pin>>>(pin: OP) -> Self;
// Provided methods
fn with_pin(pin: &'static dyn Pin) -> Self
where Self: Sized { ... }
fn static_using<OP: Into<OwnOrBorrow<'static, dyn Pin>>>(
pin: OP
) -> &'static mut Self
where Self: Sized { ... }
fn static_with_pin(pin: &'static dyn Pin) -> &'static mut Self
where Self: Sized { ... }
}
Expand description
Convenience trait implemented by any devices that use (and are constructed with) an I/O pin.
Required Methods§
sourcefn using<OP: Into<OwnOrBorrow<'static, dyn Pin>>>(pin: OP) -> Self
fn using<OP: Into<OwnOrBorrow<'static, dyn Pin>>>(pin: OP) -> Self
Create an instance of this device that uses the given instance of a pin (by ownership or reference.)
Provided Methods§
sourcefn with_pin(pin: &'static dyn Pin) -> Selfwhere
Self: Sized,
fn with_pin(pin: &'static dyn Pin) -> Selfwhere
Self: Sized,
Convenience method to create an instance of this device with a given static reference to a pin (avoids a certain amount of type hinting boilerplate for the caller.)
sourcefn static_using<OP: Into<OwnOrBorrow<'static, dyn Pin>>>(
pin: OP
) -> &'static mut Selfwhere
Self: Sized,
fn static_using<OP: Into<OwnOrBorrow<'static, dyn Pin>>>(
pin: OP
) -> &'static mut Selfwhere
Self: Sized,
Create an instance of this device that uses the given instance of a pin, and return a static reference good for the lifetime of the program.
§Note
This method leaks memory, deliberately - the create instance will never be freed. In our intended embedded environment, this is entirely deliberate.
sourcefn static_with_pin(pin: &'static dyn Pin) -> &'static mut Selfwhere
Self: Sized,
fn static_with_pin(pin: &'static dyn Pin) -> &'static mut Selfwhere
Self: Sized,
Create an instance of this device that uses the given reference to a pin, and return a static reference good for the lifetime of the program.
§Note
This method leaks memory, deliberately - the create instance will never be freed. In our intended embedded environment, this is entirely deliberate.