Skip to main content

Playground

Struct Playground 

Source
pub struct Playground { /* private fields */ }
Expand description

A real practice directory with a tracked working directory per session.

Implementations§

Source§

impl Playground

Source

pub fn open(root: PathBuf) -> Result<Self>

Open (creating on demand) the playground at root.

Source

pub fn open_with_display( root: PathBuf, display: impl Into<String>, ) -> Result<Self>

Open a playground whose paths are shown to the learner under display (e.g. ~/ArcAcademy/home).

Source

pub fn root(&self) -> &Path

The canonicalized playground root.

Source

pub fn cwd(&self) -> &Path

The tracked working directory (absolute real path inside the root).

Source

pub fn has_lesson(&self) -> bool

Whether a lesson directory is currently active.

Source

pub fn display_cwd(&self) -> String

Friendly display path for the tracked cwd, e.g. ~/ArcAcademy/playground/file-mgmt/practice.

Source

pub fn enter_lesson( &mut self, lesson_id: &str, setup: &[SetupFile], ) -> Result<PathBuf>

Enter a lesson: create <root>/<lesson-id>/, materialize its starter files (without clobbering files the learner already changed), and cd there. Returns the lesson directory.

Source

pub fn reset_lesson(&mut self) -> Result<PathBuf>

Wipe and re-materialize the active lesson’s playground directory.

rm safety: only ever deletes inside the playground root — the target is canonicalized and its prefix verified before removal.

Source

pub fn change_directory(&mut self, target: &str) -> Result<String>

Change the tracked working directory (the cd builtin for real practice mode). The target is canonicalized and must remain inside the playground. Returns the new display path.

Trait Implementations§

Source§

impl PracticeWorld for Playground

Source§

fn locate(&self, lesson_path: &str) -> Option<PathBuf>

Real path for a path relative to the lesson home, if it stays inside
Source§

fn cwd_relative(&self) -> String

Current directory relative to the lesson home (“” at the home)
Source§

fn kind_at(&self, lesson_path: &str) -> Option<EntryKind>

What is at a path relative to the lesson home; None when the path would leave it. By default, the real file PracticeWorld::locate gives.
Source§

fn read_text(&self, lesson_path: &str) -> Option<String>

A text file’s contents, by a path relative to the lesson home. By default, read from the real file PracticeWorld::locate gives.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more