21 lines
615 B
Rust
21 lines
615 B
Rust
|
use std::io::Read;
|
||
|
|
||
|
pub struct OpendirData {
|
||
|
pub id: u32,
|
||
|
pub path: String,
|
||
|
}
|
||
|
impl OpendirData {
|
||
|
pub fn deserialize(mut u8_array_data: &[u8]) -> OpendirData {
|
||
|
if u8_array_data.len() < 9 {
|
||
|
panic!("Opendir data is expected to be bigger.");
|
||
|
}
|
||
|
let mut id: [u8; 4] = [0; 4];
|
||
|
u8_array_data
|
||
|
.read(&mut id)
|
||
|
.expect("Failed to read id from opendir packet.");
|
||
|
let id = u32::from_be_bytes(id);
|
||
|
let path = crate::packet::types::string::String::deserialize(u8_array_data).content;
|
||
|
OpendirData { id: id, path: path }
|
||
|
}
|
||
|
}
|