refacto unserialize

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2022-12-19 20:25:52 +01:00
parent f567198f75
commit dcaea4454b
4 changed files with 11 additions and 16 deletions

@ -27,14 +27,6 @@ struct IsoPathTable {
}
impl IsoPathTable {
pub fn from(mapping: &u8) -> &Self {
let ptr: *const u8 = mapping;
let path_table_ptr: *const Self = ptr as *const Self;
unsafe {
&*path_table_ptr
}
}
#[allow(unaligned_references)]
pub fn get_idf(&self) -> &[u8] {
unsafe {
@ -77,14 +69,6 @@ pub struct IsoDir {
}
impl IsoDir {
pub fn from(mapping: &u8) -> &Self {
let ptr: *const u8 = mapping;
let path_table_ptr: *const Self = ptr as *const Self;
unsafe {
&*path_table_ptr
}
}
#[allow(unaligned_references)]
pub fn get_idf(&self) -> &[u8] {
unsafe {

@ -8,6 +8,7 @@ mod interrupts;
mod memory;
mod task;
mod fs;
mod utils;
//#[macro_use]
extern crate alloc;

3
src/utils/mod.rs Normal file

@ -0,0 +1,3 @@
pub mod serialize;
pub use serialize::unserialize;

7
src/utils/serialize.rs Normal file

@ -0,0 +1,7 @@
pub fn unserialize<T>(mapping: &u8) -> &T {
let ptr: *const u8 = mapping;
let path_table_ptr: *const T = ptr as *const T;
unsafe {
&*path_table_ptr
}
}