pub struct Target { /* private fields */ }Expand description
A directory devset manages.
Implementations§
Source§impl Target
impl Target
Sourcepub fn find(dir: &Utf8Path) -> Result<Self>
pub fn find(dir: &Utf8Path) -> Result<Self>
The target containing dir: the nearest ancestor holding .devset/config.toml.
§Errors
TargetError::NotFound, no ancestor holds one.TargetError::OldConfig, itsconfig.tomlis devset 0.1’s.Error::Parse, one of its files does not parse.
Sourcepub fn open_or_new(root: &Utf8Path) -> Result<Self>
pub fn open_or_new(root: &Utf8Path) -> Result<Self>
The target rooted at root, or a new one there, its config.toml a commented skeleton.
Never one inside another target.
§Errors
TargetError::Nested,rootlies inside another target.TargetError::OldConfig, itsconfig.tomlis devset 0.1’s.Error::Parse, one of its files does not parse.
Sourcepub fn exists(&self) -> bool
pub fn exists(&self) -> bool
Whether config.toml exists yet: a new target’s is written by its first
commit.
Sourcepub fn add_source(&mut self, name: SourceName, source: Source) -> Result<()>
pub fn add_source(&mut self, name: SourceName, source: Source) -> Result<()>
Names source name in [sources]; written by the next commit.
Nothing changes when it already does.
§Errors
TargetError::SourceExists,namealready names another source.Error::Parse,sourcesinconfig.tomlis not a table.
Sourcepub fn add_layer(&mut self, layer: LayerSpec) -> Result<()>
pub fn add_layer(&mut self, layer: LayerSpec) -> Result<()>
Appends layer as the last layer; written by the next commit.
§Errors
TargetError::DuplicateLayer, a layer already applies the profile.TargetError::NoSuchSource,[sources]does not name its source.Error::Parse,layersinconfig.tomlis not a list of tables.
Sourcepub fn layer(&self, name: &ProfileName) -> Option<&LayerSpec>
pub fn layer(&self, name: &ProfileName) -> Option<&LayerSpec>
The layer that applies the profile named name.
Sourcepub fn remove_layer(&mut self, name: &ProfileName) -> Result<()>
pub fn remove_layer(&mut self, name: &ProfileName) -> Result<()>
Removes the layer that applies the profile named name; written by the next
commit. Its source stays, for another layer to use.
Every [files] override that picks it, from = "<name>", goes with it.
§Errors
Error::Parse, config.toml changed shape so that the layer
cannot be found in it.
Sourcepub fn remove_override(&mut self, path: &RelPath) -> Result<()>
pub fn remove_override(&mut self, path: &RelPath) -> Result<()>
Removes the [files."path"] override; written by the next commit.
§Errors
Error::Parse, as add_layer.
Sourcepub fn answer(&mut self, name: VarName, value: String)
pub fn answer(&mut self, name: VarName, value: String)
Answers name; written by the next commit.
Sourcepub const fn answers(&self) -> &BTreeMap<VarName, String>
pub const fn answers(&self) -> &BTreeMap<VarName, String>
Every answer: recorded, or given since.
Sourcepub fn rescaffold(&mut self, scaffold: ScaffoldId)
pub fn rescaffold(&mut self, scaffold: ScaffoldId)
Writes the absent files of scaffold again at the next survey,
whatever was decided of it.