pub enum OsFunctionCall {
Show 23 variants
Exists(MontyPath),
IsFile(MontyPath),
IsDir(MontyPath),
IsSymlink(MontyPath),
ReadText(MontyPath),
ReadBytes(MontyPath),
Stat(MontyPath),
Iterdir(MontyPath),
Resolve(MontyPath),
Absolute(MontyPath),
WriteText(PathStringDataArgs),
AppendText(PathStringDataArgs),
WriteBytes(PathBytesDataArgs),
AppendBytes(PathBytesDataArgs),
Open(OpenCallArgs),
Mkdir(MkdirCallArgs),
Unlink(MontyPath),
Rmdir(MontyPath),
Rename(RenameCallArgs),
Getenv(GetenvArgs),
GetEnviron,
DateToday,
DateTimeNow(Option<MontyTimeZone>),
}Expand description
Tagged dispatch value for OS-level operations.
Each variant carries the strongly-typed args/kwargs the corresponding OS
call needs. The fs/ layer matches on this enum directly (no MontyObject
introspection); host bindings get a generic (positional, keyword) view
via OsFunctionCall::to_args.
See the module docs for how to add a new variant.
Variants§
Exists(MontyPath)
Check if a path exists.
IsFile(MontyPath)
Check if path is a regular file.
IsDir(MontyPath)
Check if path is a directory.
IsSymlink(MontyPath)
Check if path is a symbolic link.
ReadText(MontyPath)
Read file contents as text.
ReadBytes(MontyPath)
Read file contents as bytes.
Stat(MontyPath)
stat() — return a stat result tuple.
Iterdir(MontyPath)
List directory contents.
Resolve(MontyPath)
Resolve symlinks and return absolute path.
Absolute(MontyPath)
Absolute path without symlink resolution.
WriteText(PathStringDataArgs)
Write text to file (truncating).
AppendText(PathStringDataArgs)
Append text to file.
WriteBytes(PathBytesDataArgs)
Write bytes to file (truncating).
AppendBytes(PathBytesDataArgs)
Append bytes to file.
Open(OpenCallArgs)
Open a file. The host performs the open-time effect (truncate for
w/w+, create-if-missing for a/a+, existence check for r/r+)
and returns a MontyObject::FileHandle — it never holds a live OS
handle across calls.
Mkdir(MkdirCallArgs)
Create directory (parents/exist_ok kwargs).
Unlink(MontyPath)
Remove file.
Rmdir(MontyPath)
Remove directory.
Rename(RenameCallArgs)
Rename / move (src → dst).
Getenv(GetenvArgs)
Get an environment variable value.
GetEnviron
Get the entire environment as a dictionary.
DateToday
Get today’s date from the host system (for date.today()).
DateTimeNow(Option<MontyTimeZone>)
Get the current date/time from the host system (for datetime.now(tz=...)).
Carries the timezone argument, None for a naive result.
Implementations§
Source§impl OsFunctionCall
impl OsFunctionCall
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Stable string name for this OS function — surfaces in
Self::on_no_handler errors, host os callbacks, and serialised
snapshots. The strum serialize string on each variant.
Sourcepub fn to_args(self) -> (Vec<MontyObject>, Vec<(MontyObject, MontyObject)>)
pub fn to_args(self) -> (Vec<MontyObject>, Vec<(MontyObject, MontyObject)>)
Projects this call’s args into (positional, keyword) MontyObject
vectors for delivery to a host callback.
Sourcepub fn is_write(&self) -> bool
pub fn is_write(&self) -> bool
Whether this call mutates filesystem state — the read-only-mount gate.
Open’s write-ness is mode-dependent (w/w+/a/a+ write; r/r+
don’t).
Sourcepub fn is_existence_check(&self) -> bool
pub fn is_existence_check(&self) -> bool
Whether this operation checks existence without reading content.
Existence checks return false for nonexistent paths rather than
raising FileNotFoundError, matching CPython’s pathlib.Path.
Sourcepub fn embedded_null_message(&self, for_destination: bool) -> &'static str
pub fn embedded_null_message(&self, for_destination: bool) -> &'static str
CPython’s ValueError message for a path containing a null byte.
The wording is not uniform in CPython: it comes from whichever layer
first inspects the path, so the content operations go through open()
and say embedded null byte, while the metadata ones are named by the
syscall their os wrapper was about to make. for_destination picks
the rename argument that carried the byte.
Sourcepub fn fs_primary_path(&self) -> Option<&str>
pub fn fs_primary_path(&self) -> Option<&str>
The call’s primary path if it’s a FS operation, None otherwise.
Used for routing and error reporting.
Sourcepub fn rename_destination(&self) -> Option<&str>
pub fn rename_destination(&self) -> Option<&str>
The rename destination path, or None for every other variant — the
second routing key a mount table needs (both rename endpoints must
resolve to the same mount).
Sourcepub fn on_no_handler(&self) -> MontyException
pub fn on_no_handler(&self) -> MontyException
Exception to raise when no handler accepted this call: PermissionError
for FS ops (with the path), RuntimeError for non-FS ops.
Trait Implementations§
Source§impl Clone for OsFunctionCall
impl Clone for OsFunctionCall
Source§fn clone(&self) -> OsFunctionCall
fn clone(&self) -> OsFunctionCall
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more