feat(secure): a lot of things
This commit is contained in:
parent
92c81e7126
commit
2b9f55e4d2
24 changed files with 435 additions and 98 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use std::io;
|
||||
use std::io::{Read, Seek};
|
||||
use std::io::{Read, Seek, Write};
|
||||
use bytemuck::bytes_of;
|
||||
use log::error;
|
||||
use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions};
|
||||
use crate::rmc::response::{ErrorCode, RMCResponseResult};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RMCMessage{
|
||||
pub protocol_id: u16,
|
||||
pub call_id: u32,
|
||||
|
|
@ -52,6 +53,23 @@ impl RMCMessage{
|
|||
})
|
||||
}
|
||||
|
||||
pub fn to_data(&self) -> Vec<u8>{
|
||||
let size = (1 + 4 + 4 + self.rest_of_data.len()) as u32;
|
||||
|
||||
let mut output = Vec::new();
|
||||
|
||||
output.write_all(bytes_of(&size)).expect("unable to write size");
|
||||
|
||||
let proto_id = self.protocol_id as u8;
|
||||
|
||||
output.write_all(bytes_of(&proto_id)).expect("unable to write size");
|
||||
|
||||
output.write_all(bytes_of(&self.call_id)).expect("unable to write size");
|
||||
output.write_all(bytes_of(&self.method_id)).expect("unable to write size");
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
pub fn error_result_with_code(&self, error_code: ErrorCode) -> RMCResponseResult{
|
||||
RMCResponseResult::Error {
|
||||
call_id: self.call_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue