pub struct TaskExecutionKey {
pub host: NatString,
pub task_name: String,
}Expand description
A unique identifier for tracking task execution state for a specific host and task combination.
This structure serves as a composite key used by the State structure to track the
execution state of tasks on individual hosts. Each TaskExecutionKey uniquely identifies
a task execution by combining the hostname with the task name, allowing the state tracking
system to maintain separate execution histories for different task/host pairs.
The key is used internally by methods like State::set_task_state, State::task_state,
and their _key variants to store and retrieve TaskAttemptState information.
§Fields
-
host- ANatStringrepresenting the hostname on which the task is being executed. UsingNatStringprovides efficient string handling with natural sorting capabilities, which can be useful when displaying or organizing task execution results by hostname. -
task_name- The name of the task being executed. This is a standardStringthat identifies the specific task or operation being performed on the host. Task names should be unique within a playbook or execution context to ensure proper state tracking.
§Examples
// Create a task execution key for a specific host and task
let key = TaskExecutionKey::new("router1", "show_version");
assert_eq!(key.host, NatString::from("router1"));
assert_eq!(key.task_name, "show_version");
// Keys can be used to track task state
let state = State::new();
let task_state = TaskAttemptState::new(TaskStatus::Running).with_attempts(1);
state.set_task_state_key(key.clone(), task_state.clone());
assert_eq!(state.task_state_key(&key), Some(task_state));// Keys with the same host and task name are equal
let key1 = TaskExecutionKey::new("router1", "show_version");
let key2 = TaskExecutionKey::new("router1", "show_version");
assert_eq!(key1, key2);
// Keys with different hosts or task names are not equal
let key3 = TaskExecutionKey::new("router2", "show_version");
assert_ne!(key1, key3);Fields§
§host: NatString§task_name: StringImplementations§
Source§impl TaskExecutionKey
impl TaskExecutionKey
Sourcepub fn new(host: impl Into<String>, task_name: impl Into<String>) -> Self
pub fn new(host: impl Into<String>, task_name: impl Into<String>) -> Self
Creates a new TaskExecutionKey from a host and task name.
This constructor method creates a unique identifier for tracking task execution state
by combining a hostname with a task name. The resulting key can be used with methods
like State::set_task_state_key and State::task_state_key to store and retrieve
task execution information.
The host parameter is converted into a NatString for efficient string handling with
natural sorting capabilities, while the task name is stored as a standard String.
§Parameters
-
host- The hostname for which the task is being executed. Can be any type that converts into aString, such as&str,String, or other string-like types. This will be stored as aNatStringin the resulting key. -
task_name- The name of the task being executed. Can be any type that converts into aString, such as&str,String, or other string-like types. Task names should be unique within a playbook or execution context to ensure proper state tracking.
§Returns
Returns a new TaskExecutionKey instance with the specified host and task name,
ready to be used for tracking task execution state.
§Examples
// Create a key using string slices
let key = TaskExecutionKey::new("router1", "show_version");
assert_eq!(key.host, NatString::from("router1"));
assert_eq!(key.task_name, "show_version");// Create a key using owned Strings
let host = String::from("router2");
let task = String::from("configure_interface");
let key = TaskExecutionKey::new(host, task);
assert_eq!(key.task_name, "configure_interface");Trait Implementations§
Source§impl Clone for TaskExecutionKey
impl Clone for TaskExecutionKey
Source§fn clone(&self) -> TaskExecutionKey
fn clone(&self) -> TaskExecutionKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TaskExecutionKey
impl Debug for TaskExecutionKey
impl Eq for TaskExecutionKey
Source§impl Hash for TaskExecutionKey
impl Hash for TaskExecutionKey
Source§impl PartialEq for TaskExecutionKey
impl PartialEq for TaskExecutionKey
Source§fn eq(&self, other: &TaskExecutionKey) -> bool
fn eq(&self, other: &TaskExecutionKey) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TaskExecutionKey
Auto Trait Implementations§
impl Freeze for TaskExecutionKey
impl RefUnwindSafe for TaskExecutionKey
impl Send for TaskExecutionKey
impl Sync for TaskExecutionKey
impl Unpin for TaskExecutionKey
impl UnsafeUnpin for TaskExecutionKey
impl UnwindSafe for TaskExecutionKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.