2020
2121use super :: { settings:: NetworkConnection , types:: Device } ;
2222use crate :: http:: { BaseHTTPClient , BaseHTTPClientError } ;
23- use url :: form_urlencoded :: byte_serialize ;
23+ use crate :: utils :: url :: encoded ;
2424
2525#[ derive( Debug , thiserror:: Error ) ]
2626pub enum NetworkClientError {
@@ -57,8 +57,7 @@ impl NetworkClient {
5757
5858 /// Returns an array of network connections
5959 pub async fn connection ( & self , id : & str ) -> Result < NetworkConnection , NetworkClientError > {
60- let encoded_id: String = byte_serialize ( id. as_bytes ( ) ) . collect ( ) ;
61- let encoded_id = encoded_id. replace ( "+" , "%20" ) ;
60+ let encoded_id = encoded ( id. to_string ( ) ) ;
6261 let json = self
6362 . client
6463 . get :: < NetworkConnection > ( format ! ( "/network/connections/{encoded_id}" ) . as_str ( ) )
@@ -73,8 +72,7 @@ impl NetworkClient {
7372 connection : NetworkConnection ,
7473 ) -> Result < ( ) , NetworkClientError > {
7574 let id = connection. id . clone ( ) ;
76- let encoded_id: String = byte_serialize ( id. as_bytes ( ) ) . collect ( ) ;
77- let encoded_id = encoded_id. replace ( "+" , "%20" ) ;
75+ let encoded_id = encoded ( id. to_string ( ) ) ;
7876 let response = self . connection ( id. as_str ( ) ) . await ;
7977
8078 if response. is_ok ( ) {
0 commit comments