pub fn delete_state(
        &mut self,
        context_id: &ContextId,
        key: &str,
    ) -> Result<Option<Vec<u8>>, ContextManagerError> {
        // Adding a StateChange::Delete to the specified Context, which will occur no matter which
        // Context or State the key and associated value is found in.
        let context_value = self.get_context_mut(context_id)?.delete_state(key);
        if let Some(value) = context_value {
            return Ok(Some(value));
        }

        let current_context = self.get_context(context_id)?;
        let mut containing_context = self.get_context(context_id)?;

        let mut contexts = VecDeque::new();
        contexts.push_front(containing_context);
        // Adding dependent Contexts to search for the Key
        for context_id in containing_context.base_contexts().iter() {
            contexts.push_back(self.get_context(context_id)?);
        }

        while let Some(context) = contexts.pop_front() {
            if context.contains(&key) {
                containing_context = context;
                break;
            } else {
                for context_id in context.base_contexts().iter() {
                    contexts.push_back(self.get_context(context_id)?);
                }
            }
        }
        if containing_context.contains(&key) {
            if let Some(v) = containing_context.get_state(&key) {
                return Ok(Some(v.to_vec()));
            }
        } else if let Some(value) = self
            .database
            .get(current_context.state_id(), &[key.to_string()])?
            .get(&key.to_string())
        {
            return Ok(Some(value.to_vec()));
        }
        Ok(None)
    }
/// Adds a StateChange::Delete to the specified Context, returning the value, if found, that is
/// associated with the specified key.
Adds a StateChange::Delete to the specified Context, returning the value, if found, that is
associated with the specified key.
Adds a StateChange :: Delete to the specified Context returning the value if found that is associated with the specified key .
pub fn delete_state(
        &mut self,
        context_id: &ContextId,
        key: &str,
    ) -> Result<Option<Vec<u8>>, ContextManagerError> {
        // Adding a StateChange::Delete to the specified Context, which will occur no matter which
        // Context or State the key and associated value is found in.
        let context_value = self.get_context_mut(context_id)?.delete_state(key);
        if let Some(value) = context_value {
            return Ok(Some(value));
        }
        let current_context = self.get_context(context_id)?;
        let mut containing_context = self.get_context(context_id)?;
        let mut contexts = VecDeque::new();
        contexts.push_front(containing_context);
        // Adding dependent Contexts to search for the Key
        for context_id in containing_context.base_contexts().iter() {
            contexts.push_back(self.get_context(context_id)?);
        }
        while let Some(context) = contexts.pop_front() {
            if context.contains(&key) {
                containing_context = context;
                break;
            } else {
                for context_id in context.base_contexts().iter() {
                    contexts.push_back(self.get_context(context_id)?);
                }
            }
        }
        if containing_context.contains(&key) {
            if let Some(v) = containing_context.get_state(&key) {
                return Ok(Some(v.to_vec()));
            }
        } else if let Some(value) = self
            .database
            .get(current_context.state_id(), &[key.to_string()])?
            .get(&key.to_string())
        {
            return Ok(Some(value.to_vec()));
        }
        Ok(None)
    }
pub fn delete_state ( & mut self , context_id : & ContextId , key : & str , ) -> Result < Option < Vec < u8 > > , ContextManagerError > { // Adding a StateChange::Delete to the specified Context, which will occur no matter which // Context or State the key and associated value is found in. let context_value = self . get_context_mut ( context_id ) ? . delete_state ( key ) ; if let Some ( value ) = context_value { return Ok ( Some ( value ) ) ; } let current_context = self . get_context ( context_id ) ? ; let mut containing_context = self . get_context ( context_id ) ? ; let mut contexts = VecDeque :: new ( ) ; contexts . push_front ( containing_context ) ; // Adding dependent Contexts to search for the Key for context_id in containing_context . base_contexts ( ) . iter ( ) { contexts . push_back ( self . get_context ( context_id ) ? ) ; } while let Some ( context ) = contexts . pop_front ( ) { if context . contains ( & key ) { containing_context = context ; break ; } else { for context_id in context . base_contexts ( ) . iter ( ) { contexts . push_back ( self . get_context ( context_id ) ? ) ; } } } if containing_context . contains ( & key ) { if let Some ( v ) = containing_context . get_state ( & key ) { return Ok ( Some ( v . to_vec ( ) ) ) ; } } else if let Some ( value ) = self . database . get ( current_context . state_id ( ) , & [ key . to_string ( ) ] ) ? . get ( & key . to_string ( ) ) { return Ok ( Some ( value . to_vec ( ) ) ) ; } Ok ( None ) }
Adds a StateChange::Delete to the specified Context, returning the value, if found, that is
associated with the specified key.
Adds a StateChange :: Delete to the specified Context returning the value if found that is associated with the specified key .
&mut self
context_id
&ContextId
key
&str
&mut self
context_id
&ContextId
key
&str