pub struct SkillSet { /* private fields */ }Expand description
A collection of embedded skills, in name order.
Implementations§
Source§impl SkillSet
impl SkillSet
Sourcepub fn from_include_dir(dir: &'static Dir<'static>) -> Result<Self>
pub fn from_include_dir(dir: &'static Dir<'static>) -> Result<Self>
Reads skills from an include_dir tree.
The macro’s root is the skills directory itself, which holds one directory per skill:
use include_dir::{Dir, include_dir};
use skill_embed::SkillSet;
static SKILLS_DIR: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/skills");
let skills = SkillSet::from_include_dir(&SKILLS_DIR).expect("the embedded skills are valid");§Errors
Fails when a skill carries no SKILL_FILE, when two skills claim one
name, or when a file an operating system left behind was embedded with
them.
Sourcepub fn read_dir(root: &Path) -> Result<Self>
pub fn read_dir(root: &Path) -> Result<Self>
Reads skills from a directory on disk.
This is what a tool that does not embed its skills uses, and what a test uses to build the set a fixture describes.
§Errors
Fails for the reasons SkillSet::from_include_dir does, and when the
directory cannot be read.
Sourcepub fn from_files(files: impl IntoIterator<Item = File>) -> Result<Self>
pub fn from_files(files: impl IntoIterator<Item = File>) -> Result<Self>
Reads skills from an arbitrary set of files, each path separated with
/ and relative to the skills directory.
It is what SkillSet::from_include_dir and SkillSet::read_dir are
written in terms of, and what a tool embedding its skills some other way
uses.
§Errors
Fails when a skill carries no SKILL_FILE, when two skills claim one
name, or when a file an operating system left behind was embedded with
them.
Sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
The skill names, in the same order as SkillSet::skills.