pub struct SimRegistry { /* private fields */ }Expand description
Loaded view of the registry, keyed by alias.
Implementations§
Source§impl SimRegistry
impl SimRegistry
Sourcepub fn register(
path: &Path,
alias: &str,
sim: RegisteredSim,
) -> Result<RegisterOutcome, RegistryError>
pub fn register( path: &Path, alias: &str, sim: RegisteredSim, ) -> Result<RegisterOutcome, RegistryError>
Write sim into the registry under alias.
One key, not a whole file. The read-modify-write this replaces lost an alias whenever two processes registered at once — each read the file, each inserted its own row, and the second write erased the first, with no error on either side.
Sourcepub fn allow_destructive(
path: &Path,
device_ref: &str,
) -> Result<(String, bool), RegistryError>
pub fn allow_destructive( path: &Path, device_ref: &str, ) -> Result<(String, bool), RegistryError>
Allow destructive actions on one registered device, once.
Goes through Self::register rather than rewriting the file,
for the reason that function documents: a read-modify-write of the
whole registry loses a concurrent registration silently. One key
in, one key out.
Returns the alias it was recorded against and whether it was already allowed — the caller can then say “already allowed” instead of implying something changed.
§Errors
RegistryError::UnknownDevice when nothing matches the ref. The
opt-in is per device, so there is nothing to record it against —
and silently creating an entry would mean allowing destruction on
a device nobody registered.
Sourcepub fn load(path: &Path) -> Result<Self, RegistryError>
pub fn load(path: &Path) -> Result<Self, RegistryError>
Read every registered sim.
path may be the .smix directory or a legacy sims.json
inside it; both land on the same store.
Sourcepub fn discover(start: &Path) -> Option<PathBuf>
pub fn discover(start: &Path) -> Option<PathBuf>
Walk up from start looking for a .smix that holds a
registry — either the store or a legacy sims.json.
Sourcepub fn resolve(&self, device_ref: &str) -> Result<String, RegistryError>
pub fn resolve(&self, device_ref: &str) -> Result<String, RegistryError>
Resolve a device ref to the identifier its platform is addressed by.
CoreSimulator-form input passes through whether or not it is
registered. Otherwise the ref must match an alias key, a
deviceName, or the registered identifier itself.
That last one was missing until 2026-08-06, and Self::lookup
had it — so the two disagreed about whether a device’s own
identifier names it. A real phone found the disagreement: an iOS
device UDID is 25 characters, not CoreSimulator’s 36, so it fell
past the short-circuit into a search that never looked at the one
field it matched. smix runner forward 00008120-… answered
“unknown device ref” about a device that was registered right
there in the file it was reading.
Sourcepub fn sims(&self) -> &BTreeMap<String, RegisteredSim>
pub fn sims(&self) -> &BTreeMap<String, RegisteredSim>
All registered sims, keyed by alias.
Sourcepub fn lookup(&self, device_ref: &str) -> Option<&RegisteredSim>
pub fn lookup(&self, device_ref: &str) -> Option<&RegisteredSim>
Look up a RegisteredSim by alias key, device name, or UDID.
Returns None if no entry matches any of the three. Mirrors
Self::resolve’s match precedence so cli callers can fetch
the full spec (e.g. locale field) after they already resolved
the UDID.