pub struct Directives {
pub enabled: bool,
}Expand description
Emits directives for the wrapper shell, or does nothing when the binary runs outside of it.
Directives go to stderr and are flushed immediately, so they are in place before any prompt that follows. Write errors are ignored: a closed stderr leaves the player’s shell unchanged, which is the only sensible outcome.
Fields§
§enabled: booltrue when SHELLGAME_WRAPPER is set, i.e. a shell function will replay the output.
Implementations§
Source§impl Directives
impl Directives
Sourcepub fn new(enabled: bool) -> Self
pub fn new(enabled: bool) -> Self
Creates an emitter. Pass false outside the wrapper: nobody would replay the lines and
they would be printed to the player as noise.
Sourcepub fn cd(&self, path: impl AsRef<Path>)
pub fn cd(&self, path: impl AsRef<Path>)
Asks the shell to change its working directory to path.
The shell moves with the plain cd implementation, never through the player-facing hook,
so teleports are exempt from level restrictions.
Sourcepub fn export(
&self,
name: &str,
value: impl AsRef<OsStr>,
) -> Result<(), InvalidName>
pub fn export( &self, name: &str, value: impl AsRef<OsStr>, ) -> Result<(), InvalidName>
Asks the shell to set and export name=value. The value may be any string or path; its raw
bytes are sent.
§Errors
Returns InvalidName (and emits nothing) unless name matches
^[A-Za-z_][A-Za-z0-9_]*$. The name is checked even when directives are disabled, so a
mistake surfaces in tests that run outside the wrapper.
Trait Implementations§
Source§impl Clone for Directives
impl Clone for Directives
Source§fn clone(&self) -> Directives
fn clone(&self) -> Directives
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Directives
Source§impl Debug for Directives
impl Debug for Directives
Source§impl Default for Directives
impl Default for Directives
Source§fn default() -> Directives
fn default() -> Directives
impl Eq for Directives
Source§impl PartialEq for Directives
impl PartialEq for Directives
impl StructuralPartialEq for Directives
Auto Trait Implementations§
impl Freeze for Directives
impl RefUnwindSafe for Directives
impl Send for Directives
impl Sync for Directives
impl Unpin for Directives
impl UnsafeUnpin for Directives
impl UnwindSafe for Directives
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.