use crate::types::AutocmdCallbackArgs;
use crate::Buffer;
use crate::StringOrInt;
pub type ShouldDeleteAutocmd = bool;
#[cfg(feature = "neovim-0-10")] #[derive(Clone, Debug, Default, macros::OptsBuilder)]
#[repr(C)]
pub struct CreateAutocmdOpts {
#[builder(mask)]
mask: u64,
#[builder(argtype = "Buffer", inline = "{0}.0")]
buffer: types::BufHandle,
#[builder(
generics = r#"F: Into<types::Function<AutocmdCallbackArgs, ShouldDeleteAutocmd>>"#,
argtype = "F",
inline = "{0}.into().into()"
)]
callback: types::Object,
#[builder(
generics = "S: Into<types::String>",
argtype = "S",
inline = "{0}.into()"
)]
command: types::String,
#[builder(
generics = "S: Into<types::String>",
argtype = "S",
inline = "{0}.into()"
)]
desc: types::String,
#[builder(
generics = "G: StringOrInt",
argtype = "G",
inline = "{0}.to_object()"
)]
group: types::Object,
#[builder(argtype = "bool")]
nested: types::Boolean,
#[builder(argtype = "bool")]
once: types::Boolean,
#[builder(
generics = "'a, I: IntoIterator<Item = &'a str>",
method = "patterns",
argtype = "I",
inline = "types::Array::from_iter({0}).into()"
)]
pattern: types::Object,
}
#[cfg(not(feature = "neovim-0-10"))] #[derive(Clone, Debug, Default)]
#[repr(C)]
pub struct CreateAutocmdOpts {
desc: types::Object,
once: types::Object,
group: types::Object,
buffer: types::Object,
nested: types::Object,
command: types::Object,
pattern: types::Object,
callback: types::Object,
}
#[cfg(not(feature = "neovim-0-10"))] impl CreateAutocmdOpts {
#[inline(always)]
pub fn builder() -> CreateAutocmdOptsBuilder {
CreateAutocmdOptsBuilder::default()
}
}
#[cfg(not(feature = "neovim-0-10"))] #[derive(Clone, Default)]
pub struct CreateAutocmdOptsBuilder(CreateAutocmdOpts);
#[cfg(not(feature = "neovim-0-10"))] impl CreateAutocmdOptsBuilder {
#[inline]
pub fn buffer(&mut self, buffer: Buffer) -> &mut Self {
self.0.buffer = buffer.into();
self
}
#[inline]
pub fn callback<F>(&mut self, callback: F) -> &mut Self
where
F: Into<types::Function<AutocmdCallbackArgs, ShouldDeleteAutocmd>>,
{
self.0.callback = callback.into().into();
self
}
#[inline]
pub fn command<S>(&mut self, command: S) -> &mut Self
where
S: Into<types::String>,
{
self.0.command = command.into().into();
self
}
#[inline]
pub fn desc<S>(&mut self, desc: S) -> &mut Self
where
S: Into<types::String>,
{
self.0.desc = desc.into().into();
self
}
#[inline]
pub fn group<Grp>(&mut self, group: Grp) -> &mut Self
where
Grp: StringOrInt,
{
self.0.group = group.to_object();
self
}
#[inline]
pub fn nested(&mut self, nested: bool) -> &mut Self {
self.0.nested = nested.into();
self
}
#[inline]
pub fn once(&mut self, once: bool) -> &mut Self {
self.0.once = once.into();
self
}
#[inline]
pub fn patterns<'a, I>(&mut self, patterns: I) -> &mut Self
where
I: IntoIterator<Item = &'a str>,
{
self.0.pattern = types::Array::from_iter(patterns).into();
self
}
#[inline]
pub fn build(&mut self) -> CreateAutocmdOpts {
std::mem::take(&mut self.0)
}
}