File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " pbbot-rq"
3- version = " 0.1.6 "
3+ version = " 0.1.7 "
44edition = " 2021"
55
66# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ pub enum RCError {
1717 Timeout ,
1818 #[ error( "client_not_found error" ) ]
1919 ClientNotFound ,
20+ #[ error( "protocol_not_supported error" ) ]
21+ ProtocolNotSupported ,
2022 #[ error( "io error, {0}" ) ]
2123 IO ( #[ from] io:: Error ) ,
2224 #[ error( "websocket error, {0}" ) ]
@@ -39,6 +41,7 @@ impl IntoResponse for RCError {
3941 fn into_response ( self ) -> Response {
4042 let code = match self {
4143 Self :: ClientNotFound => StatusCode :: BAD_REQUEST ,
44+ Self :: ProtocolNotSupported => StatusCode :: BAD_REQUEST ,
4245 _ => StatusCode :: INTERNAL_SERVER_ERROR ,
4346 } ;
4447 ( code, self . to_string ( ) ) . into_response ( )
Original file line number Diff line number Diff line change @@ -72,7 +72,11 @@ pub struct CreateClientResp {
7272pub async fn create ( Json ( req) : Json < CreateClientReq > ) -> RCResult < Json < CreateClientResp > > {
7373 let rand_seed = req. device_seed . unwrap_or_else ( rand:: random) ;
7474 let device = Device :: random_with_rng ( & mut StdRng :: seed_from_u64 ( rand_seed) ) ;
75- let protocol = Protocol :: from_u8 ( req. protocol ) ;
75+ let protocol = match Protocol :: from_u8 ( req. protocol ) {
76+ Protocol :: MacOS => Protocol :: MacOS ,
77+ Protocol :: AndroidWatch => Protocol :: AndroidWatch ,
78+ _ => return Err ( RCError :: ProtocolNotSupported ) ,
79+ } ;
7680 let ( sender, receiver) = tokio:: sync:: broadcast:: channel ( 10 ) ;
7781 let cli = Arc :: new ( Client :: new ( device, get_version ( protocol) , sender) ) ;
7882 let stream = tokio:: net:: TcpStream :: connect ( cli. get_address ( ) )
You can’t perform that action at this time.
0 commit comments