pub struct WslProviderRecord {
pub schema_version: u32,
pub distribution: String,
pub task_name: String,
pub installed_version: String,
pub last_verified: DateTime<Utc>,
}Expand description
One managed WSL distribution, as this workstation last saw it.
Every field is non-secret and every field is checkable against reality.
Fields§
§schema_version: u32The schema this document was written under.
distribution: StringThe exact distribution name, as wsl --list spells it.
task_name: StringThe Task Scheduler name of the lifecycle task.
installed_version: StringThe runner-manager version last installed inside the distribution.
last_verified: DateTime<Utc>When the provider last verified the distribution’s actual state.
Implementations§
Source§impl WslProviderRecord
impl WslProviderRecord
Sourcepub fn new(
distribution: impl Into<String>,
task_name: impl Into<String>,
installed_version: impl Into<String>,
at: DateTime<Utc>,
) -> Self
pub fn new( distribution: impl Into<String>, task_name: impl Into<String>, installed_version: impl Into<String>, at: DateTime<Utc>, ) -> Self
A record for a distribution this workstation now manages.
Sourcepub fn path(paths: &AppPaths, distribution: &str) -> Result<PathBuf, WslError>
pub fn path(paths: &AppPaths, distribution: &str) -> Result<PathBuf, WslError>
Where one distribution’s record lives.
The file name is derived the same way the task name is, by the same
function — [super::discovery::escaped_name_with_digest] — so two
distributions whose names escape alike cannot share a file.
§Errors
WslError::InvalidName for a distribution name that cannot be used.
Sourcepub fn read(
paths: &AppPaths,
distribution: &str,
) -> Result<Option<Self>, WslError>
pub fn read( paths: &AppPaths, distribution: &str, ) -> Result<Option<Self>, WslError>
Reads a distribution’s record, if there is one.
§Errors
WslError::InvalidName; WslError::Record when the file exists
and cannot be read or parsed; WslError::RecordSchema when it was
written by a version this one does not understand.
Sourcepub fn write(&self, paths: &AppPaths) -> Result<(), WslError>
pub fn write(&self, paths: &AppPaths) -> Result<(), WslError>
Writes the record, replacing any previous one atomically.
§Atomic, and why it has to be
The document is written to a temporary file in the same directory,
flushed to disk, and renamed onto its destination — so a reader either
sees the previous record or the new one, never a half-written one. A
truncated record is not a cosmetic problem: it is what
WslProviderRecord::read would refuse to parse, on a machine whose
provisioning had in fact succeeded.
§Errors
Sourcepub fn remove(paths: &AppPaths, distribution: &str) -> Result<bool, WslError>
pub fn remove(paths: &AppPaths, distribution: &str) -> Result<bool, WslError>
Removes a distribution’s record. Returns whether there was one.
This is the whole of what wsl detach deletes on the Windows side
besides the task: nothing inside the distribution, and nothing else in
the config directory.
§Errors
Sourcepub fn all(paths: &AppPaths) -> Result<Vec<Self>, WslError>
pub fn all(paths: &AppPaths) -> Result<Vec<Self>, WslError>
Every record this workstation holds, in file-name order.
A file that does not parse is reported rather than skipped: a config
directory with a damaged record is something an operator should be told
about, not something wsl list should quietly show one fewer row for.
§Errors
Trait Implementations§
Source§impl Clone for WslProviderRecord
impl Clone for WslProviderRecord
Source§fn clone(&self) -> WslProviderRecord
fn clone(&self) -> WslProviderRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more