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 moreSource§impl Debug for OsFunctionCall
impl Debug for OsFunctionCall
Source§impl<'de> Deserialize<'de> for OsFunctionCall
impl<'de> Deserialize<'de> for OsFunctionCall
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OsFunctionCall, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OsFunctionCall, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for OsFunctionCall
impl Display for OsFunctionCall
Source§impl Serialize for OsFunctionCall
impl Serialize for OsFunctionCall
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<Call> for OsFunctionCall
impl TryFrom<Call> for OsFunctionCall
Source§type Error = ProtoConvertError
type Error = ProtoConvertError
Source§fn try_from(call: Call) -> Result<OsFunctionCall, ProtoConvertError>
fn try_from(call: Call) -> Result<OsFunctionCall, ProtoConvertError>
Auto Trait Implementations§
impl Freeze for OsFunctionCall
impl RefUnwindSafe for OsFunctionCall
impl Send for OsFunctionCall
impl Sync for OsFunctionCall
impl Unpin for OsFunctionCall
impl UnsafeUnpin for OsFunctionCall
impl UnwindSafe for OsFunctionCall
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToCharString for Twhere
T: Display,
impl<T> ToCharString for Twhere
T: Display,
Source§fn try_to_char_string(&self) -> Result<CharString, ToCharStringError>
fn try_to_char_string(&self) -> Result<CharString, ToCharStringError>
CharString. Read moreSource§fn to_char_string(&self) -> CharString
fn to_char_string(&self) -> CharString
CharString. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more