Skip to main content

AgentSkill

Struct AgentSkill 

Source
pub struct AgentSkill { /* private fields */ }
Expand description

A program’s skill on the user’s machine.

use agent_skill_installer::{AgentSkill, Program, Skill};

let skill = Skill::new("mytool", "Use mytool to do the thing.", "# mytool\n")?;
let program = Program::new("mytool", "1.2.0")?;
let agent = AgentSkill::new(skill, program, "/data/mytool/skill-consent")?;

agent.update()?; // at start, without asking
if let Some(offer) = agent.offer()? {
    // Ask once in your own surface, naming offer.steps().
    offer.accept()?; // or offer.decline()?
}

Implementations§

Source§

impl AgentSkill

Source

pub fn new( skill: Skill, program: Program, consent_file: impl Into<PathBuf>, ) -> Result<Self, Error>

The skill for the user running the program, with the built-in tools.

consent_file is where the places the user declined are kept; the program’s own data directory is the natural home for it.

§Errors

Returns Error::NoHome when the process has no home directory.

Source

pub fn with_environment(self, env: Environment) -> Self

The same, looking at another environment: a test’s temporary home.

Source

pub fn with_catalog(self, catalog: Catalog) -> Self

The same, with a catalog the program extended or replaced.

Source

pub const fn catalog(&self) -> &Catalog

The tools and folders it knows, for naming them to people.

Source

pub const fn installer(&self) -> Installer<'_>

The installer underneath, for a program that decides place by place.

Source

pub fn status(&self) -> Result<Assessment, Error>

Every place and what would happen there. Writes nothing.

§Errors

Returns an error when the answers cannot be read or no plan can be made.

Source

pub fn update(&self) -> Result<Vec<Outcome>, Error>

Bring every copy this program installed and nobody changed up to the running version. Asks nothing and installs nothing new; meant for every start of the program.

§Errors

Returns an error when no plan can be made.

Source

pub fn offer(&self) -> Result<Option<Offer<'_>>, Error>

The question to ask, when a place exists nobody has decided on.

§Errors

Returns an error when the answers cannot be read or no plan can be made.

Source

pub fn install_everywhere(&self) -> Result<Vec<Outcome>, Error>

Install wherever the skill can go, also where the user declined before: for an explicit request such as an install command.

§Errors

Returns an error when the answers cannot be read or written, or no plan can be made.

Source

pub fn remove(&self) -> Result<Vec<Outcome>, Error>

Remove every copy this program installed and nobody changed.

§Errors

Returns an error when no plan can be made.

Trait Implementations§

Source§

impl Debug for AgentSkill

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.