[−][src]Struct rair_io::RIO
Methods
impl RIO
[src]
pub fn new() -> RIO
[src]
pub fn load_plugin(&mut self, plugin: Box<dyn RIOPlugin>)
[src]
THIS FUNCTION IS NOT SUPPOSED TO BE THAT TRIVIAL I WANT IT TO LITERALLY OPEN A PLUGIN FILE
pub fn open(&mut self, uri: &str, flags: IoMode) -> Result<u64, IoError>
[src]
Allows us to open file and have it accessable from out physical address space,
open will automatically load the file in the smallest available physical address while
RIO::open_at will allow user to determine what physical address to use. uri
is
used to describe file path as well as data encoding if needed. flags
is used to
describe permision used while opening file.
Return value
the unique file handler represented by [u64] is returned. In case of error, an IoError is returned explaining why opening file failed.
Example
use rair_io::RIO; use rair_io::IoMode; let mut io = RIO::new(); io.open("hello.txt", IoMode::READ);
pub fn open_at(
&mut self,
uri: &str,
flags: IoMode,
at: u64
) -> Result<u64, IoError>
[src]
&mut self,
uri: &str,
flags: IoMode,
at: u64
) -> Result<u64, IoError>
Allows us to open file and have it accessable from out physical address space
at physicall address of out choice, uri
is used to describe file path as
well as data encoding if needed. flags
is used to describe permision used
while opening file.
Return value
the unique file handler represented by [u64] is returned. In case of error, an IoError is returned explaining why opening file failed.
Example
use rair_io::{RIO, IoMode, IoError}; fn main() -> Result<(), IoError> { let mut io = RIO::new(); io.open_at("hello.txt", IoMode::READ | IoMode::WRITE, 0x4000)?; return Ok(()); }
pub fn close(&mut self, hndl: u64) -> Result<(), IoError>
[src]
Close an opened file, delete its physical and virtual address space. In case of Error, an IoError is returned explaining why close failed.
Example
use rair_io::RIO; use rair_io::IoMode; use rair_io::IoError; fn main() -> Result<(), IoError> { let mut io = RIO::new(); let hndl = io.open("hello.txt", IoMode::READ)?; io.close(hndl)?; return Ok(()); }
pub fn close_all(&mut self)
[src]
Close all open files, and reset all virtual and physical address spaces.
Example
use rair_io::RIO; use rair_io::IoMode; use rair_io::IoError; fn main() -> Result<(), IoError> { let mut io = RIO::new(); io.open("foo.txt", IoMode::READ)?; io.open("bar.txt", IoMode::READ)?; io.close_all(); return Ok(()); }
pub fn pread(&mut self, paddr: u64, buf: &mut [u8]) -> Result<(), IoError>
[src]
Read from the physical address space of current RIO object. If there is no enough data to fill buf an error is returned.
Example
use rair_io::RIO; use rair_io::IoMode; let mut io = RIO::new(); io.open_at("foo.txt", IoMode::READ, 0x20); let mut fillme: Vec<u8> = vec![0; 8]; io.pread(0x20, &mut fillme);
pub fn pread_sparce(
&mut self,
paddr: u64,
size: u64
) -> Result<BTreeMap<u64, u8>, IoError>
[src]
&mut self,
paddr: u64,
size: u64
) -> Result<BTreeMap<u64, u8>, IoError>
Read from the physical address space of current RIO object. Data is stored in a sparce vector represented by BTreeMap. Error is returned only in case of internal IO errors.
Example
use rair_io::RIO; use rair_io::IoMode; let mut io = RIO::new(); io.open_at("foo.txt", IoMode::READ, 0x20); let data = io.pread_sparce(0x20, 0x50); //reads at most 0x50 bytes from foo.txt
pub fn pwrite(&mut self, paddr: u64, buf: &[u8]) -> Result<(), IoError>
[src]
Write into the physical address space of current RIO object. If there is no enough space to accomodate buf an error is returned.
Example
use rair_io::RIO; use rair_io::IoMode; let mut io = RIO::new(); io.open_at("foo.txt", IoMode::READ, 0x20); let fillme: Vec<u8> = vec![0; 8]; io.pwrite(0x20, &fillme);
pub fn map(&mut self, paddr: u64, vaddr: u64, size: u64) -> Result<(), IoError>
[src]
Map memory regions from physical address space to virtual address space
pub fn unmap(&mut self, vaddr: u64, size: u64) -> Result<(), IoError>
[src]
unmap already mapped regions
pub fn vread(&mut self, vaddr: u64, buf: &mut [u8]) -> Result<(), IoError>
[src]
read memory from virtual address space. If there is no enough data to fill buf an error is returned.
pub fn vread_sparce(
&mut self,
vaddr: u64,
size: u64
) -> Result<BTreeMap<u64, u8>, IoError>
[src]
&mut self,
vaddr: u64,
size: u64
) -> Result<BTreeMap<u64, u8>, IoError>
read memory from virtual address space. Data is stored in a sparce vector represented by BTreeMap. Error is returned only in case of internal IO errors.
pub fn vwrite(&mut self, vaddr: u64, buf: &[u8]) -> Result<(), IoError>
[src]
write memory into virtual address space
pub fn vir_to_phy(&self, vaddr: u64, size: u64) -> Option<Vec<RIOMap>>
[src]
convert virtual address to physical address
pub fn phy_to_vir(&self, phy: u64) -> Vec<u64>
[src]
This funciton reverse-queries individual physical addresses. It convert physical address to virtual address. The return value is a vector of virtual addresses, all of which would map to the provided physical address
pub fn uri_iter<'a>(&'a self) -> Box<dyn Iterator<Item = &'a RIODesc> + 'a>
[src]
Iterate over open URIs
pub fn map_iter<'a>(&'a self) -> Box<dyn Iterator<Item = Rc<RIOMap>> + 'a>
[src]
Iterate over memory maps
pub fn hndl_to_desc(&self, hndl: u64) -> Option<&RIODesc>
[src]
Trait Implementations
impl Default for RIO
[src]
impl<'de> Deserialize<'de> for RIO
[src]
fn deserialize<D>(d: D) -> Result<RIO, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Serialize for RIO
[src]
Auto Trait Implementations
impl !RefUnwindSafe for RIO
impl !Send for RIO
impl !Sync for RIO
impl Unpin for RIO
impl !UnwindSafe for RIO
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,