@@ -111,23 +111,6 @@ pub struct CompleteState {
111111/// Struct containing the attributes of an agent of the [Ankaios] system.
112112///
113113/// [Ankaios]: https://eclipse-ankaios.github.io/ankaios
114- ///
115- /// # Examples
116- ///
117- /// ## Get the attributes of an agent:
118- ///
119- /// ```rust
120- /// # use ankaios_sdk::AgentAttributes;
121- /// # use std::collections::HashMap;
122- /// #
123- /// # let agent_attributes = AgentAttributes {
124- /// # tags: HashMap::new(),
125- /// # status: HashMap::new(),
126- /// # };
127- /// #
128- /// let tags = &agent_attributes.tags;
129- /// let status = &agent_attributes.status;
130- /// ```
131114#[ derive( Debug , Clone , PartialEq ) ]
132115pub struct AgentAttributes {
133116 /// A map of custom tags as key-value pairs.
@@ -404,22 +387,16 @@ impl CompleteState {
404387 ) {
405388 let agent_name_str = agent_name. into ( ) ;
406389
407- if self . complete_state . agents . is_none ( ) {
408- self . complete_state . agents = Some ( ank_base:: AgentMap {
409- agents : HashMap :: new ( ) ,
410- } ) ;
411- }
412-
413- if let Some ( agent_map) = self . complete_state . agents . as_mut ( ) {
414- let agent_attributes = agent_map. agents . entry ( agent_name_str) . or_insert_with ( || {
415- ank_base:: AgentAttributes {
390+ let agent_map = self . complete_state . agents . get_or_insert_default ( ) ;
391+ let agent_attributes =
392+ agent_map
393+ . agents
394+ . entry ( agent_name_str)
395+ . or_insert_with ( || ank_base:: AgentAttributes {
416396 status : None ,
417397 tags : None ,
418- }
419- } ) ;
420-
421- agent_attributes. tags = Some ( ank_base:: Tags { tags } ) ;
422- }
398+ } ) ;
399+ agent_attributes. tags = Some ( ank_base:: Tags { tags } ) ;
423400 }
424401
425402 /// Sets the configurations of the `CompleteState`.
0 commit comments