nvim_api/types/
command_args.rs1use nvim_types::{
2 conversion::{self, FromObject},
3 serde::Deserializer,
4 Object,
5};
6use serde::Deserialize;
7
8use crate::serde_utils as utils;
9
10#[non_exhaustive]
15#[derive(Clone, Debug, Eq, PartialEq, Hash, Deserialize)]
16pub struct CommandArgs {
17 #[serde(deserialize_with = "utils::empty_string_is_none")]
19 pub args: Option<String>,
20
21 pub bang: bool,
23
24 #[serde(deserialize_with = "utils::minus_one_is_none")]
26 pub count: Option<u32>,
27
28 pub fargs: Vec<String>,
30
31 pub line1: usize,
33
34 pub line2: usize,
36
37 #[serde(deserialize_with = "utils::empty_string_is_none")]
39 pub mods: Option<String>,
40
41 pub range: u8,
43
44 #[serde(rename = "reg", deserialize_with = "utils::empty_string_is_none")]
46 pub register: Option<String>,
47
48 #[cfg(any(feature = "neovim-0-8", feature = "neovim-nightly"))]
50 #[cfg_attr(
51 docsrs,
52 doc(cfg(any(feature = "neovim-0-8", feature = "neovim-nightly")))
53 )]
54 pub smods: super::CommandModifiers,
55}
56
57impl FromObject for CommandArgs {
58 fn from_object(obj: Object) -> Result<Self, conversion::Error> {
59 Self::deserialize(Deserializer::new(obj)).map_err(Into::into)
60 }
61}
62
63impl luajit_bindings::Poppable for CommandArgs {
64 unsafe fn pop(
65 lstate: *mut luajit_bindings::ffi::lua_State,
66 ) -> Result<Self, luajit_bindings::Error> {
67 let obj = Object::pop(lstate)?;
68
69 Self::from_object(obj)
70 .map_err(luajit_bindings::Error::pop_error_from_err::<Self, _>)
71 }
72}