nvim_oxi_api/opts/
buf_delete.rs

1/// Options passed to [`Buffer::delete()`](crate::Buffer::delete).
2#[derive(Clone, Debug, Default)]
3#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
4pub struct BufDeleteOpts {
5    force: types::Object,
6    unload: types::Object,
7}
8
9#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
10impl BufDeleteOpts {
11    #[inline(always)]
12    pub fn builder() -> BufDeleteOptsBuilder {
13        BufDeleteOptsBuilder::default()
14    }
15}
16
17#[derive(Clone, Default)]
18#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
19pub struct BufDeleteOptsBuilder(BufDeleteOpts);
20
21#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
22impl BufDeleteOptsBuilder {
23    /// Force deletion ignoring unsaved changes.
24    #[inline]
25    pub fn force(&mut self, force: bool) -> &mut Self {
26        self.0.force = force.into();
27        self
28    }
29
30    /// If `true` the buffer will only be unloaded, not deleted.
31    #[inline]
32    pub fn unload(&mut self, unload: bool) -> &mut Self {
33        self.0.unload = unload.into();
34        self
35    }
36
37    #[inline]
38    pub fn build(&mut self) -> BufDeleteOpts {
39        std::mem::take(&mut self.0)
40    }
41}
42
43#[cfg(not(feature = "neovim-0-10"))] // 0nly on 0.9.
44impl From<&BufDeleteOpts> for types::Dictionary {
45    fn from(opts: &BufDeleteOpts) -> Self {
46        Self::from_iter([
47            ("force", opts.force.clone()),
48            ("unload", opts.unload.clone()),
49        ])
50    }
51}
52
53/// Options passed to [`Buffer::attach`](crate::Buffer::attach).
54#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
55#[derive(Clone, Debug, Default, macros::OptsBuilder)]
56#[repr(C)]
57pub struct BufDeleteOpts {
58    #[builder(mask)]
59    mask: u64,
60
61    /// Force deletion ignoring unsaved changes.
62    #[builder(argtype = "bool")]
63    force: types::Boolean,
64
65    /// If `true` the buffer will only be unloaded, not deleted.
66    #[builder(argtype = "bool")]
67    unload: types::Boolean,
68}