@@ -41,7 +41,8 @@ impl Bank {
4141}
4242
4343impl GenServer for Bank {
44- type InMsg = InMessage ;
44+ type CallMsg = InMessage ;
45+ type CastMsg = ( ) ;
4546 type OutMsg = MsgResult ;
4647 type Error = BankError ;
4748 type State = BankState ;
@@ -52,19 +53,19 @@ impl GenServer for Bank {
5253
5354 async fn handle_call (
5455 & mut self ,
55- message : InMessage ,
56+ message : Self :: CallMsg ,
5657 _handle : & BankHandle ,
5758 state : & mut Self :: State ,
5859 ) -> CallResponse < Self :: OutMsg > {
5960 match message. clone ( ) {
60- InMessage :: New { who } => match state. get ( & who) {
61+ Self :: CallMsg :: New { who } => match state. get ( & who) {
6162 Some ( _amount) => CallResponse :: Reply ( Err ( BankError :: AlreadyACustomer { who } ) ) ,
6263 None => {
6364 state. insert ( who. clone ( ) , 0 ) ;
6465 CallResponse :: Reply ( Ok ( OutMessage :: Welcome { who } ) )
6566 }
6667 } ,
67- InMessage :: Add { who, amount } => match state. get ( & who) {
68+ Self :: CallMsg :: Add { who, amount } => match state. get ( & who) {
6869 Some ( current) => {
6970 let new_amount = current + amount;
7071 state. insert ( who. clone ( ) , new_amount) ;
@@ -75,7 +76,7 @@ impl GenServer for Bank {
7576 }
7677 None => CallResponse :: Reply ( Err ( BankError :: NotACustomer { who } ) ) ,
7778 } ,
78- InMessage :: Remove { who, amount } => match state. get ( & who) {
79+ Self :: CallMsg :: Remove { who, amount } => match state. get ( & who) {
7980 Some ( current) => match current < & amount {
8081 true => CallResponse :: Reply ( Err ( BankError :: InsufficientBalance {
8182 who,
@@ -92,13 +93,13 @@ impl GenServer for Bank {
9293 } ,
9394 None => CallResponse :: Reply ( Err ( BankError :: NotACustomer { who } ) ) ,
9495 } ,
95- InMessage :: Stop => CallResponse :: Stop ( Ok ( OutMessage :: Stopped ) ) ,
96+ Self :: CallMsg :: Stop => CallResponse :: Stop ( Ok ( OutMessage :: Stopped ) ) ,
9697 }
9798 }
9899
99100 async fn handle_cast (
100101 & mut self ,
101- _message : InMessage ,
102+ _message : Self :: CastMsg ,
102103 _handle : & BankHandle ,
103104 _state : & mut Self :: State ,
104105 ) -> CastResponse {
0 commit comments