documentation and nit fix

This commit is contained in:
Kunal Mohan 2021-03-22 09:05:08 +05:30
parent bc2345c413
commit 660434be06
3 changed files with 7 additions and 3 deletions

View file

@ -164,7 +164,7 @@ impl IpcSenderWithContext {
}
pub fn send<T: Serialize>(&mut self, msg: T) -> ipmpsc::Result<()> {
self.sender.send(&(self.err_ctx, msg))
self.sender.send(&(msg, self.err_ctx))
}
}
@ -573,7 +573,7 @@ pub fn start(
.spawn({
let recv_client_instructions = IpcReceiver::new(client_buffer);
move || loop {
let (err_ctx, instruction): (ErrorContext, ClientInstruction) =
let (instruction, err_ctx): (ClientInstruction, ErrorContext) =
recv_client_instructions.recv().unwrap();
send_app_instructions.update(err_ctx);
match instruction {

View file

@ -180,7 +180,10 @@ pub trait ServerOsApi: Send + Sync {
fn kill(&mut self, pid: RawFd) -> Result<(), nix::Error>;
/// Returns a [`Box`] pointer to this [`OsApi`] struct.
fn box_clone(&self) -> Box<dyn ServerOsApi>;
/// Returns the receiver of ServerInstructions.
// Should be called by server once only.
fn get_server_receiver(&self) -> IpcReceiver;
/// Returns a sender to the Server.
fn get_server_sender(&self) -> IpcSenderWithContext;
}
@ -264,6 +267,7 @@ pub trait ClientOsApi: Send + Sync {
fn read_from_stdin(&self) -> Vec<u8>;
/// Returns a [`Box`] pointer to this [`OsApi`] struct.
fn box_clone(&self) -> Box<dyn ClientOsApi>;
/// Returns a sender to the Server.
fn get_server_sender(&self) -> IpcResult<IpcSenderWithContext>;
}

View file

@ -147,7 +147,7 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, opts: CliArgs) -> thread::Jo
// For now, We make sure that the first message is `NewClient` so there are no out of bound panics.
let mut send_client_instructions: Vec<IpcSenderWithContext> = Vec::with_capacity(1);
move || loop {
let (mut err_ctx, instruction): (ErrorContext, ServerInstruction) =
let (instruction, mut err_ctx): (ServerInstruction, ErrorContext) =
recv_server_instructions.recv().unwrap();
err_ctx.add_call(ContextType::IPCServer(ServerContext::from(&instruction)));
send_pty_instructions.update(err_ctx);