pub fn write_command<W: Write, T: Serialize>
    (stream : &mut W, code: u8, obj : &T) -> Result<(), Error> {

    if let Err(_) = stream.write(&[code]) {
        return Err(Error::NetworkWriteError)
    }

    write_to_stream::<W, T>(stream, obj)
}
/// This function should be used to write a command (i.e., send a request)
/// It is similar to `write_to_stream`, however this function writes a byte before the JSON object
/// to indicate the command code, which has to be managed outside of this library
///
/// Returns a `Result` to simply indicate if the write succeeded
///
/// # Arguments
///
/// * `stream` - The output stream
/// * `code` - The command code
/// * `obj` - The instance of the struct to write
This function should be used to write a command
It is similar to `write_to_stream`, however this function writes a byte before the JSON object
to indicate the command code, which has to be managed outside of this library

Returns a `Result` to simply indicate if the write succeeded
This function should be used to write a command It is similar to ` write_to_stream ` however this function writes a byte before the JSON object to indicate the command code which has to be managed outside of this library Returns a ` Result ` to simply indicate if the write succeeded
pub fn write_command<W: Write, T: Serialize>
    (stream : &mut W, code: u8, obj : &T) -> Result<(), Error> {
    if let Err(_) = stream.write(&[code]) {
        return Err(Error::NetworkWriteError)
    }
    write_to_stream::<W, T>(stream, obj)
}
pub fn write_command < W : Write , T : Serialize > ( stream : & mut W , code : u8 , obj : & T ) -> Result < ( ) , Error > { if let Err ( _ ) = stream . write ( & [ code ] ) { return Err ( Error :: NetworkWriteError ) } write_to_stream :: < W , T > ( stream , obj ) }
This function should be used to write a command (i.e., send a request)
It is similar to `write_to_stream`, however this function writes a byte before the JSON object
to indicate the command code, which has to be managed outside of this library
This function should be used to write a command ( i . e . send a request ) It is similar to ` write_to_stream ` however this function writes a byte before the JSON object to indicate the command code which has to be managed outside of this library
stream
&mut W
code
u8
obj
&T
stream
&mut W
code
u8
obj
&T