pub struct Config { /* private fields */ }
Expand description

The configuration for a request for one or more lines.

The configuration for a subset of lines is updated by selecting the lines and then calling the appropriate mutators. If no lines are selected then the mutators modify the base configuration that lines inherit when they are first added.

Examples

   use gpiocdev::line::{Bias::*, Value::*};
   use gpiocdev::request::Config;

   let cfg = Config::default()
       .as_input()
       .with_bias(PullUp)
       // -- base config ends here - just before lines are added.
       .with_lines(&[3, 5, 8]) // lines 3,5,8 will be input with pull-up bias...
       // -- config added here would apply to lines 3,5 and 8
       .with_line(3) // make line 3 pull-down instead...
       .with_bias(PullDown)
       .with_line(4) // and line 4 an output set inactive (and pull-up from the base)
       .as_output(Inactive);

Note that the configuration is applied to hardware via a call to Builder.request or Request.reconfigure. Changes to the Config object, either before or after that only update the configuration in memory in preparation for the next application.

Implementations

Set the chip from which to request lines.

This applies to all lines in the request. It is not possible to request lines from different chips in the same request.

The chip is identified by a path which must resolve to a GPIO character device.

Set the selected lines to input.

This is a short form of with_direction(Input).

This is the default direction setting.

Do not set the direction of the selected lines.

Set the selected lines to output with the given value.

This is a long form of with_direction(Output) that allows the value to be set in the same call.

Set the selected lines to active low.

Set the selected lines to active high.

This is the default active level setting.

Set the bias setting for the selected lines.

Set the debounce period for the selected lines.

Implicitly selects the lines as inputs, if they weren’t already, and removes any output specific settings.

Set the direction of the selected lines.

Setting to input removes any output specific settings.

Setting to output removes any input specific settings.

Note that selecting a line as output will default its value to inactive. To provide a value use with_value, or use as_output(value) instead.

To determine the state of en existing output line, first request it as_is, then reconfigure it as an output with an appropriate value.

Set the drive setting for the selected lines.

Implicitly sets the lines as outputs, if they weren’t already, and removes any input specific settings.

Set the edge detection for the selected lines.

Implicitly sets the lines as inputs and removes any output specific settings.

Set the clock source for edge events on the selected lines.

Add a found line to the config.

The line must be on the same chip as any existing lines in the request.

Note that all configuration mutators applied subsequently only apply to this line.

Examples
let led0 = gpiocdev::find_named_line("LED0").unwrap();
let mut cfg = Config::default();
cfg.with_found_line(&led0)?
   .as_output(Value::Active);

Add a set of found lines to the config.

The lines must be on the same chip as any existing lines in the request.

Note that all configuration mutators applied subsequently only apply to these lines.

Examples
let buttons = gpiocdev::find_named_lines(&["BUTTON0","BUTTON1"], true)?;
let mut cfg = Config::default();
cfg.with_found_lines(&buttons)?
   .with_edge_detection(EdgeDetection::BothEdges);

Add a line to the config.

Note that all configuration mutators applied subsequently only apply to this line.

Remove a lines from the config.

Add a set of lines to the config.

Note that all configuration mutators applied subsequently only apply to this subset of lines.

Passing empty offsets re-selects the base config for subsequent mutations.

Remove a set of lines from the config.

Set the value of the selected lines.

This is only relevant for output lines and is ignored for input lines.

Apply the configuration based on the snapshot from a single line.

Get the requested configuration for a particular line.

This is the configuration that would be applied to the line if request were to be called.

Returns the set of lines described by the Config.

Lines are in the order first added by calls to with_line or with_lines.

Returns the number of lines currently described by the Config.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.