Skip to main content

SessionTargetHandle

Struct SessionTargetHandle 

Source
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>

Source

pub fn get_value(&self, key: &str) -> Result<Option<MetaValue>>

Get a metadata value by key.

Source

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()))?; // explicit

Uses the session’s email and timestamp automatically.

Source

pub fn remove(&self, key: &str) -> Result<bool>

Remove a metadata key.

Uses the session’s email and timestamp automatically.

Source

pub fn list_push(&self, key: &str, value: &str) -> Result<()>

Push a value onto a list.

Uses the session’s email and timestamp automatically.

Source

pub fn list_pop(&self, key: &str, value: &str) -> Result<()>

Pop a value from a list.

Uses the session’s email and timestamp automatically.

Source

pub fn list_remove(&self, key: &str, index: usize) -> Result<()>

Remove a list entry by index.

Uses the session’s email and timestamp automatically.

Source

pub fn set_add(&self, key: &str, value: &str) -> Result<()>

Add a member to a set.

Uses the session’s email and timestamp automatically.

Source

pub fn set_remove(&self, key: &str, value: &str) -> Result<()>

Remove a member from a set.

Uses the session’s email and timestamp automatically.

Source

pub fn target(&self) -> &Target

The target this handle is scoped to.

Source

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.

Source

pub fn list_entries(&self, key: &str) -> Result<Vec<ListEntry>>

Get list entries for a key on this target.

§Parameters
  • key: the metadata key name
§Returns

A vector of ListEntry values with resolved content and timestamps.

§Errors

Returns an error if the key is missing, the value is not a list, or the database read fails.

Source

pub fn get_authorship(&self, key: &str) -> Result<Option<Authorship>>

Get authorship info (last author email and timestamp) for a key on this target.

§Parameters
  • key: the metadata key name
§Returns

Some(Authorship) if the key has been modified at least once, None otherwise.

§Errors

Returns an error if the database read fails.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.