Trait xplm::data::ArrayRead

source ·
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§

source

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.

source

fn len(&self) -> usize

Returns the length of the data array

Provided Methods§

source

fn as_vec(&self) -> Vec<T::Element>
where T::Element: Default + Clone,

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());
    }

Implementors§

source§

impl<A> ArrayRead<[f32]> for DataRef<[f32], A>

source§

impl<A> ArrayRead<[f32]> for OwnedData<[f32], A>

source§

impl<A> ArrayRead<[i8]> for DataRef<[i8], A>

source§

impl<A> ArrayRead<[i8]> for OwnedData<[i8], A>

source§

impl<A> ArrayRead<[i32]> for DataRef<[i32], A>

source§

impl<A> ArrayRead<[i32]> for OwnedData<[i32], A>

source§

impl<A> ArrayRead<[u8]> for DataRef<[u8], A>

source§

impl<A> ArrayRead<[u8]> for OwnedData<[u8], A>

source§

impl<A> ArrayRead<[u32]> for DataRef<[u32], A>

source§

impl<A> ArrayRead<[u32]> for OwnedData<[u32], A>