#[non_exhaustive]pub struct CommandArg {
pub name: String,
pub key: Option<String>,
pub type_name: String,
pub required: bool,
pub schema: Option<Value>,
}Expand description
Schema for a single argument of a registered command.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringArgument name as declared in the Rust function signature.
key: Option<String>The key the frontend must use for this argument in invoke(cmd, { key }),
when it differs from name. Tauri renames arguments to
camelCase by default (size_kb → sizeKb), so passing name would fail
with “missing required key”. None means the key equals name.
type_name: StringRust type name (e.g. “String”, “Option<u32>”).
required: boolWhether the argument must be provided (not Option).
schema: Option<Value>Optional JSON Schema for the argument’s expected shape.
Implementations§
Source§impl CommandArg
impl CommandArg
Sourcepub fn new(
name: impl Into<String>,
type_name: impl Into<String>,
required: bool,
) -> Self
pub fn new( name: impl Into<String>, type_name: impl Into<String>, required: bool, ) -> Self
Creates an argument schema with no JSON Schema attached.
§Examples
use victauri_core::{CommandArg, CommandInfo};
let cmd = CommandInfo::new("greet")
.with_arg(CommandArg::new("name", "String", true))
.with_return_type("String");
assert_eq!(cmd.args[0].name, "name");
assert!(cmd.args[0].required);Sourcepub fn with_key(self, key: impl Into<String>) -> Self
pub fn with_key(self, key: impl Into<String>) -> Self
Sets the IPC key the frontend passes this argument under, when it differs
from the Rust name (see key).
use victauri_core::CommandArg;
let arg = CommandArg::new("size_kb", "usize", true).with_key("sizeKb");
assert_eq!(arg.invoke_key(), "sizeKb");
assert_eq!(CommandArg::new("name", "String", true).invoke_key(), "name");Sourcepub fn invoke_key(&self) -> &str
pub fn invoke_key(&self) -> &str
The key to pass this argument under in an IPC call.
Sourcepub fn with_schema(self, schema: Value) -> Self
pub fn with_schema(self, schema: Value) -> Self
Attaches a JSON Schema describing the argument’s expected shape.