#[non_exhaustive]pub struct Command<V> {
pub action: Action,
pub target: Target<V>,
pub args: Args<V>,
pub profile: Option<Nsid>,
pub command_id: Option<CommandId>,
}
Expand description
An OpenC2 command communicates an action to be performed on a target.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.action: Action
The task or activity to be performed.
target: Target<V>
The object of the action. The action is performed on the target.
args: Args<V>
§profile: Option<Nsid>
The object which will perform the action on the target.
command_id: Option<CommandId>
Implementations§
Source§impl<V> Command<V>
impl<V> Command<V>
Sourcepub fn new(action: Action, target: impl Into<Target<V>>) -> Self
pub fn new(action: Action, target: impl Into<Target<V>>) -> Self
Create a new command without an actuator.
pub fn with_args(self, args: Args<V>) -> Self
pub fn with_profile(self, profile: impl Into<Nsid>) -> Self
pub fn with_command_id(self, command_id: impl Into<CommandId>) -> Self
Sourcepub fn as_action_target(&self) -> (Action, &Target<V>)
pub fn as_action_target(&self) -> (Action, &Target<V>)
Returns the action and target of the command as a tuple.
§Usage
fn example<V>(cmd: &Command<V>) -> Result<(), Error> {
match cmd.as_action_target() {
(Action::Query, Target::Features(features)) => {
// handle feature query
Ok(())
}
(action, target) => Err(Error::not_implemented_pair(action, &target.into())),
}
}
Trait Implementations§
Source§impl<'de, V> Deserialize<'de> for Command<V>where
V: Deserialize<'de> + Default,
impl<'de, V> Deserialize<'de> for Command<V>where
V: Deserialize<'de> + Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<V> Freeze for Command<V>where
V: Freeze,
impl<V> RefUnwindSafe for Command<V>where
V: RefUnwindSafe,
impl<V> Send for Command<V>where
V: Send,
impl<V> Sync for Command<V>where
V: Sync,
impl<V> Unpin for Command<V>where
V: Unpin,
impl<V> UnwindSafe for Command<V>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more