pub struct CommandBuilder<Cmd> { /* private fields */ }Expand description
Builds MikroTik router commands using a fluid API.
Ensures that only commands with at least one operation can be built and sent.
§Examples
let cmd = CommandBuilder::new()
.command("/system/resource/print")
.attribute("detail", None)
.build();Implementations§
Source§impl CommandBuilder<NoCmd>
impl CommandBuilder<NoCmd>
Sourcepub fn login(username: &str, password: Option<&str>) -> Command
pub fn login(username: &str, password: Option<&str>) -> Command
Builds a login command with the provided username and optional password.
§Arguments
username- The username for the login command.password- An optional password for the login command.
§Returns
A Command which represents the login operation.
§Examples
let login_cmd = CommandBuilder::login("admin", Some("password"));Source§impl CommandBuilder<Cmd>
impl CommandBuilder<Cmd>
Sourcepub fn attribute_raw(self, key: &str, value: Option<&[u8]>) -> Self
pub fn attribute_raw(self, key: &str, value: Option<&[u8]>) -> Self
Adds an attribute with a raw byte value to the command being built.
Use this method when your attribute values might contain non-UTF-8 or binary data.
For regular string values, CommandBuilder<Cmd>::attribute provides a more convenient interface.
§Arguments
key- The attribute’s key (must be valid UTF-8).value- The attribute’s value as raw bytes, which is optional. IfNone, the attribute is treated as a flag.
§Returns
The builder with the attribute added, allowing for method chaining.
Sourcepub fn query_is_present(self, name: &str) -> Self
pub fn query_is_present(self, name: &str) -> Self
Adds a query to the command being built. pushes ‘true’ if an item has a value of property name, ‘false’ if it does not.
#Arguments
name: name of the property to check
§Returns
The builder with the attribute added, allowing for method chaining.
Sourcepub fn query_not_present(self, name: &str) -> Self
pub fn query_not_present(self, name: &str) -> Self
Adds a query to the command being built. pushes ‘true’ if an item has a value of property name, ‘false’ if it does not.
#Arguments
name: name of the property to check
§Returns
The builder with the attribute added, allowing for method chaining.
Sourcepub fn query_equal(self, name: &str, value: &str) -> Self
pub fn query_equal(self, name: &str, value: &str) -> Self
Adds a query to the command being built. pushes ‘true’ if the property name has a value equal to x, ‘false’ otherwise.
#Arguments
name: name of the property to comparevalue: value to be compared with
§Returns
The builder with the attribute added, allowing for method chaining.
Sourcepub fn query_gt(self, key: &str, value: &str) -> Self
pub fn query_gt(self, key: &str, value: &str) -> Self
Adds a query to the command being built. pushes ‘true’ if the property name has a value greater than x, ‘false’ otherwise.
#Arguments
name: name of the property to comparevalue: value to be compared with
§Returns
The builder with the attribute added, allowing for method chaining.
Sourcepub fn query_lt(self, key: &str, value: &str) -> Self
pub fn query_lt(self, key: &str, value: &str) -> Self
Adds a query to the command being built. pushes ‘true’ if the property name has a value less than x, ‘false’ otherwise.
#Arguments
name: name of the property to comparevalue: value to be compared with
§Returns
The builder with the attribute added, allowing for method chaining.
Sourcepub fn query_operations(
self,
operations: impl Iterator<Item = QueryOperator>,
) -> Self
pub fn query_operations( self, operations: impl Iterator<Item = QueryOperator>, ) -> Self
defines combination of defined operations https://help.mikrotik.com/docs/spaces/ROS/pages/47579160/API#API-Queries #Arguments
operations: operation sequence to be applied to the results on the stack
§Returns
The builder with the attribute added, allowing for method chaining.
Trait Implementations§
Source§impl<Cmd: Clone> Clone for CommandBuilder<Cmd>
impl<Cmd: Clone> Clone for CommandBuilder<Cmd>
Source§fn clone(&self) -> CommandBuilder<Cmd>
fn clone(&self) -> CommandBuilder<Cmd>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more