refacto unserialize
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
		
							parent
							
								
									f567198f75
								
							
						
					
					
						commit
						dcaea4454b
					
				@ -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
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										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
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										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
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user