pub trait ArrayRead<T: ArrayType + ?Sized> {
// Required methods
fn get(&self, dest: &mut [T::Element]) -> usize;
fn len(&self) -> usize;
// Provided method
fn as_vec(&self) -> Vec<T::Element>
where T::Element: Default + Clone { ... }
}
Expand description
Trait for readable array data accessors
Required Methods§
sourcefn get(&self, dest: &mut [T::Element]) -> usize
fn get(&self, dest: &mut [T::Element]) -> usize
Reads values
Values are stored in the provided slice. If the dataref is larger than the provided slice, values beyond the bounds of the slice are ignored.
If the dataref is smaller than the provided slice, the extra values in the slice will not be modified.
The maximum number of values in an array dataref is i32::MAX.
This function returns the number of values that were read.
Provided Methods§
sourcefn as_vec(&self) -> Vec<T::Element>
fn as_vec(&self) -> Vec<T::Element>
Returns all values in this accessor as a Vec
Examples found in repository?
examples/dataref.rs (line 32)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
fn test_datarefs(&mut self) {
debugln!("Has joystick: {}", self.has_joystick.get());
debugln!("Earth mu: {}", self.earth_mu.get());
debugln!("Date: {}", self.date.get());
debugln!(
"Simulator build: {}",
self.sim_build_string
.get_as_string()
.unwrap_or(String::from("Unknown"))
);
debugln!("Latitude: {}", self.latitude.get());
debugln!(
"Joystick axis values: {:?}",
self.joystick_axis_values.as_vec()
);
debugln!("Battery on: {:?}", self.battery_on.as_vec());
}