libnotcurses_sys/widgets/reader/
methods.rs

1//! `NcReader*` methods and associated functions.
2
3use super::{NcReader, NcReaderOptions};
4use crate::{c_api::ncreader_create, error_ref_mut, NcPlane, NcResult};
5
6/// # `NcReaderOptions` Constructors
7impl NcReaderOptions {
8    /// `NcReaderOptions` simple constructor.
9    pub const fn new() -> Self {
10        Self {
11            // channels used for input
12            tchannels: 0,
13            // attributes used for input
14            tattrword: 0,
15            // bitfield of NCREADER_OPTION_*
16            flags: 0,
17        }
18    }
19}
20
21/// # `NcReader` Constructors
22impl NcReader {
23    /// `NcReader` simple constructor.
24    pub fn new<'a>(plane: &mut NcPlane) -> NcResult<&'a mut Self> {
25        Self::with_options(plane, &NcReaderOptions::new())
26    }
27
28    /// `NcReader` constructor with options.
29    pub fn with_options<'a>(
30        plane: &mut NcPlane,
31        options: &NcReaderOptions,
32    ) -> NcResult<&'a mut Self> {
33        error_ref_mut![unsafe { ncreader_create(plane, options) }]
34    }
35}