pub struct Agent { /* private fields */ }Expand description
Agent encapsulates query, key, and state for trie operations.
An agent is used for:
- Lookup operations (query → key with ID)
- Reverse lookup (query with ID → key with string)
- Common prefix search
- Predictive search
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn set_query_str(&mut self, s: &str)
pub fn set_query_str(&mut self, s: &str)
Sets the query from a string slice.
Sourcepub fn set_query_bytes(&mut self, bytes: &[u8])
pub fn set_query_bytes(&mut self, bytes: &[u8])
Sets the query from a byte slice.
Sourcepub fn set_query_id(&mut self, key_id: usize)
pub fn set_query_id(&mut self, key_id: usize)
Sets the query from a key ID for reverse lookup.
Sourcepub fn state_mut(&mut self) -> Option<&mut State>
pub fn state_mut(&mut self) -> Option<&mut State>
Returns a mutable reference to the state if it exists.
Sourcepub fn set_key_str(&mut self, s: &str)
pub fn set_key_str(&mut self, s: &str)
Sets the key from a string slice.
Sourcepub fn set_key_bytes(&mut self, bytes: &[u8])
pub fn set_key_bytes(&mut self, bytes: &[u8])
Sets the key from a byte slice.
Sourcepub fn set_key_id(&mut self, id: usize)
pub fn set_key_id(&mut self, id: usize)
Sets the key ID.
Sourcepub fn set_key_from_state_buf(&mut self)
pub fn set_key_from_state_buf(&mut self)
Sets the key to point to the state’s key buffer.
This is used after operations like reverse_lookup that build the key in the state’s buffer.
Sourcepub fn set_key_from_query(&mut self)
pub fn set_key_from_query(&mut self)
Sets the key to point to the query buffer.
This is used after a successful lookup to set the result key to the query string that was searched for.
Sourcepub fn set_key_from_query_prefix(&mut self, length: usize)
pub fn set_key_from_query_prefix(&mut self, length: usize)
Sets the key to point to a prefix of the query buffer.
This is used during prefix searches to set the result key to a prefix of the query string.
§Arguments
length- Length of the prefix