138 fn process_message<C, H>(client: Client<C>, handler: H, msg: ChannelMessage) -> CommandPoll<C, H> |
138 fn process_message<C, H>(client: Client<C>, handler: H, msg: ChannelMessage) -> CommandPoll<C, H> |
139 where |
139 where |
140 C: Connection, |
140 C: Connection, |
141 H: SystemHandler, |
141 H: SystemHandler, |
142 { |
142 { |
143 match msg { |
143 { |
144 ChannelMessage::Data(b'r', data) => { |
144 match msg { |
145 let code = message::parse_result_code(data)?; |
145 ChannelMessage::Data(b'r', data) => { |
146 Ok(AsyncS::Ready((client, handler, code))) |
146 let code = message::parse_result_code(data)?; |
147 } |
147 Ok(AsyncS::Ready((client, handler, code))) |
148 ChannelMessage::Data(..) => { |
148 } |
149 // just ignores data sent to optional channel |
149 ChannelMessage::Data(..) => { |
150 let msg_loop = MessageLoop::resume(client); |
150 // just ignores data sent to optional channel |
151 Ok(AsyncS::PollAgain(CommandState::Running(msg_loop, handler))) |
151 let msg_loop = MessageLoop::resume(client); |
152 } |
152 Ok(AsyncS::PollAgain(CommandState::Running(msg_loop, handler))) |
153 ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) => Err(io::Error::new( |
153 } |
154 io::ErrorKind::InvalidData, |
154 ChannelMessage::InputRequest(..) | ChannelMessage::LineRequest(..) => Err( |
155 "unsupported request", |
155 io::Error::new(io::ErrorKind::InvalidData, "unsupported request"), |
156 )), |
156 ), |
157 ChannelMessage::SystemRequest(data) => { |
157 ChannelMessage::SystemRequest(data) => { |
158 let (cmd_type, cmd_spec) = message::parse_command_spec(data)?; |
158 let (cmd_type, cmd_spec) = message::parse_command_spec(data)?; |
159 match cmd_type { |
159 match cmd_type { |
160 CommandType::Pager => { |
160 CommandType::Pager => { |
161 let fut = handler.spawn_pager(cmd_spec).into_future(); |
161 let fut = handler.spawn_pager(cmd_spec).into_future(); |
162 Ok(AsyncS::PollAgain(CommandState::SpawningPager(client, fut))) |
162 Ok(AsyncS::PollAgain(CommandState::SpawningPager(client, fut))) |
163 } |
163 } |
164 CommandType::System => { |
164 CommandType::System => { |
165 let fut = handler.run_system(cmd_spec).into_future(); |
165 let fut = handler.run_system(cmd_spec).into_future(); |
166 Ok(AsyncS::PollAgain(CommandState::WaitingSystem(client, fut))) |
166 Ok(AsyncS::PollAgain(CommandState::WaitingSystem(client, fut))) |
|
167 } |
167 } |
168 } |
168 } |
169 } |
169 } |
170 } |
170 } |
171 } |
171 } |
172 } |