pub(crate) fn send(&self, frame: P::FrameType) -> Result<Identity, CommandErrors> {
        // Seems a fata error invalidated the current series, so everything needs to be cleared
        if *self.clear_buffer.borrow().deref() {
            self.clear_socket();
            *self.clear_buffer.borrow_mut() = false;
        }

        // Handle dropped futures for not leaking memory
        self.handle_dropped_futures();

        let mut buffer = BytesMut::new();
        if self.protocol.encode_bytes(&mut buffer, &frame).is_err() {
            return Err(CommandErrors::EncodingCommandFailed);
        }

        let mut stack = self.stack.borrow_mut();
        let mut socket = self.socket.borrow_mut();

        if stack.send(socket.deref_mut(), buffer.as_ref()).is_err() {
            return Err(CommandErrors::TcpError);
        };

        let identity = Identity {
            series: *self.current_series.borrow(),
            index: *self.next_index.borrow(),
        };
        *self.next_index.borrow_mut() += 1;
        Ok(identity)
    }
/// Encodes and sends the given command
Encodes and sends the given command
Encodes and sends the given command
pub(crate) fn send(&self, frame: P::FrameType) -> Result<Identity, CommandErrors> {
        // Seems a fata error invalidated the current series, so everything needs to be cleared
        if *self.clear_buffer.borrow().deref() {
            self.clear_socket();
            *self.clear_buffer.borrow_mut() = false;
        }
        // Handle dropped futures for not leaking memory
        self.handle_dropped_futures();
        let mut buffer = BytesMut::new();
        if self.protocol.encode_bytes(&mut buffer, &frame).is_err() {
            return Err(CommandErrors::EncodingCommandFailed);
        }
        let mut stack = self.stack.borrow_mut();
        let mut socket = self.socket.borrow_mut();
        if stack.send(socket.deref_mut(), buffer.as_ref()).is_err() {
            return Err(CommandErrors::TcpError);
        };
        let identity = Identity {
            series: *self.current_series.borrow(),
            index: *self.next_index.borrow(),
        };
        *self.next_index.borrow_mut() += 1;
        Ok(identity)
    }
pub ( crate ) fn send ( & self , frame : P :: FrameType ) -> Result < Identity , CommandErrors > { // Seems a fata error invalidated the current series, so everything needs to be cleared if * self . clear_buffer . borrow ( ) . deref ( ) { self . clear_socket ( ) ; * self . clear_buffer . borrow_mut ( ) = false ; } // Handle dropped futures for not leaking memory self . handle_dropped_futures ( ) ; let mut buffer = BytesMut :: new ( ) ; if self . protocol . encode_bytes ( & mut buffer , & frame ) . is_err ( ) { return Err ( CommandErrors :: EncodingCommandFailed ) ; } let mut stack = self . stack . borrow_mut ( ) ; let mut socket = self . socket . borrow_mut ( ) ; if stack . send ( socket . deref_mut ( ) , buffer . as_ref ( ) ) . is_err ( ) { return Err ( CommandErrors :: TcpError ) ; } ; let identity = Identity { series : * self . current_series . borrow ( ) , index : * self . next_index . borrow ( ) , } ; * self . next_index . borrow_mut ( ) += 1 ; Ok ( identity ) }
Encodes and sends the given command
Encodes and sends the given command
&self
frame
P::FrameType
&self
frame
P::FrameType