pub struct MockConn {
pub written: Mutex<Vec<u8>>,
pub read_data: Mutex<Vec<u8>>,
pub started: AtomicBool,
pub killed: AtomicBool,
pub closed: AtomicBool,
pub mock_exit_code: i32,
pub term_size: Mutex<(i64, i64)>,
pub wait_tx: Mutex<Option<Sender<()>>>,
pub wait_rx: Mutex<Option<Receiver<()>>>,
}Expand description
Mock ConnInterface for testing without a real PTY.
Fields§
§written: Mutex<Vec<u8>>Data written to this mock (simulates stdin).
read_data: Mutex<Vec<u8>>Data to return from read (simulates stdout).
started: AtomicBoolWhether the process has been started.
killed: AtomicBoolWhether the process has been killed.
closed: AtomicBoolWhether the process has been closed.
mock_exit_code: i32Exit code to return.
term_size: Mutex<(i64, i64)>Current terminal size.
wait_tx: Mutex<Option<Sender<()>>>Notify when wait should return (simulate process exit).
wait_rx: Mutex<Option<Receiver<()>>>Implementations§
Source§impl MockConn
impl MockConn
pub fn new(mock_exit_code: i32) -> Self
Sourcepub fn set_read_data(&self, data: Vec<u8>)
pub fn set_read_data(&self, data: Vec<u8>)
Set data that will be returned by read_data.
Sourcepub fn signal_exit(&self)
pub fn signal_exit(&self)
Signal that the mock process should exit.
Sourcepub fn get_written(&self) -> Vec<u8> ⓘ
pub fn get_written(&self) -> Vec<u8> ⓘ
Get all data written to the mock.
Trait Implementations§
Source§impl ConnInterface for MockConn
impl ConnInterface for MockConn
Auto Trait Implementations§
impl !Freeze for MockConn
impl !RefUnwindSafe for MockConn
impl Send for MockConn
impl Sync for MockConn
impl Unpin for MockConn
impl !UnwindSafe for MockConn
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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.