pub async fn sync(&mut self, requests: Vec<PeerRequest>) -> Result<(), ClientError> {
        let num_requests = requests.len();
        let request = Request::Sync(requests);
        request.validate().map_err(ClientError::MalformedRequest)?;

        // send the request
        request.write_into(&mut self.socket).await.map_err(|err| {
            ClientError::ConnectionError(String::from("failed to send a request"), err)
        })?;

        // read the response; there should be exactly one byte returned for every
        // peer request sent
        let mut response = vec![0u8; num_requests];
        self.socket.read_exact(&mut response).await.map_err(|err| {
            ClientError::ConnectionError(String::from("failed to get a response"), err)
        })?;

        // check if the response contains any errors
        parse_sync_response(&response)
    }
/// Instructs the Plasma Stream server to execute the specified requests.
Instructs the Plasma Stream server to execute the specified requests.
Instructs the Plasma Stream server to execute the specified requests .
pub async fn sync(&mut self, requests: Vec<PeerRequest>) -> Result<(), ClientError> {
        let num_requests = requests.len();
        let request = Request::Sync(requests);
        request.validate().map_err(ClientError::MalformedRequest)?;
        // send the request
        request.write_into(&mut self.socket).await.map_err(|err| {
            ClientError::ConnectionError(String::from("failed to send a request"), err)
        })?;
        // read the response; there should be exactly one byte returned for every
        // peer request sent
        let mut response = vec![0u8; num_requests];
        self.socket.read_exact(&mut response).await.map_err(|err| {
            ClientError::ConnectionError(String::from("failed to get a response"), err)
        })?;
        // check if the response contains any errors
        parse_sync_response(&response)
    }
pub async fn sync ( & mut self , requests : Vec < PeerRequest > ) -> Result < ( ) , ClientError > { let num_requests = requests . len ( ) ; let request = Request :: Sync ( requests ) ; request . validate ( ) . map_err ( ClientError :: MalformedRequest ) ? ; // send the request request . write_into ( & mut self . socket ) . await . map_err ( | err | { ClientError :: ConnectionError ( String :: from ( " " ) , err ) } ) ? ; // read the response; there should be exactly one byte returned for every // peer request sent let mut response = vec ! [ 0u8 num_requests ] ; self . socket . read_exact ( & mut response ) . await . map_err ( | err | { ClientError :: ConnectionError ( String :: from ( " " ) , err ) } ) ? ; // check if the response contains any errors parse_sync_response ( & response ) }
Instructs the Plasma Stream server to execute the specified requests.
Instructs the Plasma Stream server to execute the specified requests .
&mut self
requests
Vec<PeerRequest>
&mut self
requests
Vec<PeerRequest>