pub struct SessionTargetHandle<'a> { /* private fields */ }Expand description
A scoped handle for operations on a specific target within a session.
Created via Session::target(). Carries the target, email, and
timestamp from the session so callers never have to pass them.
§Example
let session = Session::discover()?;
let handle = session.target(&Target::parse("commit:abc123")?);
handle.set("agent:model", "claude")?;
let val = handle.get_value("agent:model")?;Implementations§
Source§impl<'a> SessionTargetHandle<'a>
impl<'a> SessionTargetHandle<'a>
Sourcepub fn set(&self, key: &str, value: impl Into<MetaValue>) -> Result<()>
pub fn set(&self, key: &str, value: impl Into<MetaValue>) -> Result<()>
Set a metadata value with convenience conversion.
Accepts anything that converts to MetaValue: &str, String,
Vec<ListEntry>, BTreeSet<String>, or MetaValue directly.
handle.set("key", "hello")?; // string
handle.set("key", MetaValue::String("hello".into()))?; // explicitUses the session’s email and timestamp automatically.
Sourcepub fn remove(&self, key: &str) -> Result<bool>
pub fn remove(&self, key: &str) -> Result<bool>
Remove a metadata key.
Uses the session’s email and timestamp automatically.
Sourcepub fn list_push(&self, key: &str, value: &str) -> Result<()>
pub fn list_push(&self, key: &str, value: &str) -> Result<()>
Push a value onto a list.
Uses the session’s email and timestamp automatically.
Sourcepub fn list_pop(&self, key: &str, value: &str) -> Result<()>
pub fn list_pop(&self, key: &str, value: &str) -> Result<()>
Pop a value from a list.
Uses the session’s email and timestamp automatically.
Sourcepub fn list_remove(&self, key: &str, index: usize) -> Result<()>
pub fn list_remove(&self, key: &str, index: usize) -> Result<()>
Remove a list entry by index.
Uses the session’s email and timestamp automatically.
Sourcepub fn set_add(&self, key: &str, value: &str) -> Result<()>
pub fn set_add(&self, key: &str, value: &str) -> Result<()>
Add a member to a set.
Uses the session’s email and timestamp automatically.
Sourcepub fn set_remove(&self, key: &str, value: &str) -> Result<()>
pub fn set_remove(&self, key: &str, value: &str) -> Result<()>
Remove a member from a set.
Uses the session’s email and timestamp automatically.
Sourcepub fn get_all_values(
&self,
prefix: Option<&str>,
) -> Result<Vec<(String, MetaValue)>>
pub fn get_all_values( &self, prefix: Option<&str>, ) -> Result<Vec<(String, MetaValue)>>
Get all metadata for this target as typed (key, value) pairs.
Optionally filters by key prefix (e.g., Some("agent") returns
all keys starting with agent or agent:).
§Parameters
prefix: optional key prefix to filter by
§Returns
A vector of (key, MetaValue) pairs for matching metadata entries.
§Errors
Returns an error if the database read or deserialization fails.