1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! `NcReader*` methods and associated functions.

use super::{NcReader, NcReaderOptions};
use crate::{error_ref_mut, ncreader_create, NcPlane, NcResult};

/// # `NcReaderOptions` Constructors
impl NcReaderOptions {
    /// `NcReaderOptions` simple constructor
    pub const fn new() -> Self {
        Self {
            // channels used for input
            tchannels: 0,
            // attributes used for input
            tattrword: 0,
            // bitfield of NCREADER_OPTION_*
            flags: 0,
        }
    }
}

/// # `NcReader` Constructors
impl NcReader {
    /// `NcReader` simple constructor
    pub fn new<'a>(plane: &mut NcPlane) -> NcResult<&'a mut Self> {
        Self::with_options(plane, NcReaderOptions::new())
    }

    /// `NcReader` constructor with options
    pub fn with_options<'a>(
        plane: &mut NcPlane,
        options: NcReaderOptions,
    ) -> NcResult<&'a mut Self> {
        error_ref_mut![unsafe { ncreader_create(plane, &options) }]
    }
}