Program

Struct Program 

Source
pub struct Program {
    pub filename: String,
    pub workspace: String,
    pub cells: HashMap<u32, Cell>,
}
Expand description

This is what sits in state as long as the program is running when a new request is made, it will check if the same cell has been executed by checking cells which is a HashMap

§Terms

  • temp_dir: Whatever the OS temp directory is
  • filename: Last executed filename so we can restart state if necessary
  • cells: VS Code name for a notebook cell

Fields§

§filename: String§workspace: String§cells: HashMap<u32, Cell>

Implementations§

Source§

impl Program

Source

pub fn new() -> Program

Create a new program which is retained in state between http requests

Source

pub fn create_cell(&mut self, cr: &CodeRequest)

Initial cell creation if it doesn’t exist yet Contents Use clone as we need to retain a pointer to data that will stick around after the request has finished

Source

pub fn update_cell(&mut self, cr: &CodeRequest)

As the cells are implemented with a HashMap this is a fast lookup, Only updates what’s required

Source

pub fn write_to_file(&mut self, fragment: u32)

First sorts the hashmap by index into a vector, then writes the output with rustkernel-start and rustkernel-end to determine which cell’s was executing

Source

pub fn run(&self) -> String

Run the program by running cargo run in the temp directory then uses regex to determine what part of the output to send back to the caller

Source

pub fn fmt(&self)

Trait Implementations§

Source§

impl Debug for Program

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.