complete chapter 7
This commit is contained in:
@@ -35,7 +35,15 @@ impl TicketStoreClient {
|
||||
Ok(response_receiver.recv().unwrap())
|
||||
}
|
||||
|
||||
pub fn update(&self, ticket_patch: TicketPatch) -> Result<(), OverloadedError> {}
|
||||
pub fn update(&self, ticket_patch: TicketPatch) -> Result<(), OverloadedError> {
|
||||
let (sender, receiver) = sync_channel(1);
|
||||
self.sender
|
||||
.try_send(Command::Update {
|
||||
patch: ticket_patch,
|
||||
response_channel: sender,
|
||||
})
|
||||
.map_err(|_| OverloadedError)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@@ -85,7 +93,23 @@ pub fn server(receiver: Receiver<Command>) {
|
||||
patch,
|
||||
response_channel,
|
||||
}) => {
|
||||
todo!()
|
||||
let ticket = store.get_mut(patch.id).unwrap();
|
||||
match patch.title {
|
||||
Some(a) => {
|
||||
ticket.title = a;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
match patch.status {
|
||||
Some(a) => ticket.status = a,
|
||||
None => {}
|
||||
}
|
||||
|
||||
match patch.description {
|
||||
Some(a) => ticket.description = a,
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
// There are no more senders, so we can safely break
|
||||
|
||||
Reference in New Issue
Block a user