pub struct Repl {
pub dir: TempDir,
pub stdin: ChildStdin,
pub stdout: Bytes<ChildStdout>,
pub stderr: Bytes<ChildStderr>,
pub child: Child,
pub eof: Vec<u8>,
pub socket: TcpStream,
}Expand description
Interface to the Node.js REPL. Send code with Repl::run, stop it with Repl::stop.
Fields§
§dir: TempDirNeeds to be held until the working directory should be dropped.
stdin: ChildStdinstdin to the Node.js process.
stdout: Bytes<ChildStdout>stdout from the Node.js process.
stderr: Bytes<ChildStderr>stderr from the Node.js process.
child: ChildHandle to the running Node.js process.
eof: Vec<u8>The delimiter used to end one read-eval-print-loop
socket: TcpStreamIO socket
Implementations§
Source§impl Repl
impl Repl
Sourcepub async fn drain_stderr(&mut self) -> Result<Vec<u8>>
pub async fn drain_stderr(&mut self) -> Result<Vec<u8>>
get contents of stderr
Sourcepub async fn drain_stdout(&mut self) -> Result<Vec<u8>>
pub async fn drain_stdout(&mut self) -> Result<Vec<u8>>
get contents of stdout
Sourcepub async fn run<S: AsRef<str>>(&mut self, code: S) -> Result<Vec<u8>>
pub async fn run<S: AsRef<str>>(&mut self, code: S) -> Result<Vec<u8>>
Run some JavaScript. Returns a Vec<u8> containing whatever is sent through the JavaScript
processes stdout.
Sourcepub async fn print(&mut self) -> Result<Option<(Vec<u8>, Vec<u8>)>>
pub async fn print(&mut self) -> Result<Option<(Vec<u8>, Vec<u8>)>>
Print stdout & stderr and return them.
Sourcepub async fn print_until_settled(&mut self) -> Result<()>
pub async fn print_until_settled(&mut self) -> Result<()>
Print JS stdout & stderr until there is nothing left to print
Sourcepub async fn str_run<S: AsRef<str>>(&mut self, code: S) -> Result<String>
pub async fn str_run<S: AsRef<str>>(&mut self, code: S) -> Result<String>
Run some JavaScript. Returns whatever is through Node’s stdout.
Sourcepub async fn json_run<T: DeserializeOwned, S: AsRef<str>>(
&mut self,
code: S,
) -> Result<T>
pub async fn json_run<T: DeserializeOwned, S: AsRef<str>>( &mut self, code: S, ) -> Result<T>
Run some JavaScript. Deserialize stdout into T.
Sourcepub async fn json_run_tcp<T: DeserializeOwned, S: AsRef<str>>(
&mut self,
code: S,
) -> Result<T>
pub async fn json_run_tcp<T: DeserializeOwned, S: AsRef<str>>( &mut self, code: S, ) -> Result<T>
Run some JavaScript. Deserialize stdout into T.
Sourcepub async fn get_name<T: DeserializeOwned, S: Display>(
&mut self,
name: S,
) -> Result<T>
pub async fn get_name<T: DeserializeOwned, S: Display>( &mut self, name: S, ) -> Result<T>
Run some JavaScript. Deserialize stdout into T.