[−][src]Struct iostream::io::memory::memory_stream::MemoryStream
the memory stream from memory,you can use it,wr memory
Methods
impl MemoryStream
[src]
pub fn new() -> MemoryStream
[src]
pub fn new_to(buf: &[u8]) -> MemoryStream
[src]
impl MemoryStream
[src]
pub fn to_vec(&self) -> Vec<u8>
[src]
return current stream data to Vec
pub fn clear(&mut self)
[src]
Clears the vector, removing all values,and set position =0
Trait Implementations
impl Stream for MemoryStream
[src]
fn set_position(&mut self, _potion: u64) -> Result<(), Box<dyn Error>>
[src]
fn position(&mut self) -> u64
[src]
fn length(&mut self) -> u64
[src]
fn set_length(&mut self, len: u64) -> Result<(), Box<dyn Error>>
[src]
fn can_write(&mut self) -> bool
[src]
fn can_read(&mut self) -> bool
[src]
fn can_seek(&mut self) -> bool
[src]
fn read_all(&mut self, buf: &mut Vec<u8>) -> Result<usize, StreamError>
[src]
Examples
use iostream::io::*; let mut ms=MemoryStream::new(); let data:[u8;1024]=[55;1024]; ms.write_all(&data).unwrap(); ms.set_position(0).unwrap(); let mut p:Vec<u8>=Vec::new(); ms.read_all(&mut p).unwrap(); for i in p { print!("{}",i); } println!(); ms.set_position(0).unwrap(); let mut p:Vec<u8>=vec![0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff]; ms.read_all(&mut p).unwrap(); for i in p { print!("{}",i); } println!();
fn read(
&mut self,
buf: &mut [u8],
offset: usize,
count: usize
) -> Result<usize, StreamError>
[src]
&mut self,
buf: &mut [u8],
offset: usize,
count: usize
) -> Result<usize, StreamError>
Examples
use iostream::io::*; let mut ms=MemoryStream::new(); let data:[u8;1024]=[55;1024]; ms.write_all(&data).unwrap(); ms.set_position(0).unwrap(); let mut data:Vec<u8>=vec![0;250]; let len=data.len(); let size = ms.read(&mut data, 0,len).unwrap();
fn read_byte(&mut self) -> Result<u8, StreamError>
[src]
Examples
use iostream::io::*; let data:[u8;10]=[5;10]; let mut ms= MemoryStream::new_to(&data); for s in 0..10 { let d= ms.read_byte().unwrap(); print!("{}",d); }
fn seek(
&mut self,
offset: i64,
origin: SeekOrigin
) -> Result<u64, Box<dyn Error>>
[src]
&mut self,
offset: i64,
origin: SeekOrigin
) -> Result<u64, Box<dyn Error>>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Box<dyn Error>>
[src]
Examples
use iostream::io::*; let mut ms= MemoryStream::new(); let data: [u8; 1024] = [2; 1024]; ms.write_all(&data).unwrap();
fn write(
&mut self,
buf: &[u8],
offset: usize,
count: usize
) -> Result<usize, Box<dyn Error>>
[src]
&mut self,
buf: &[u8],
offset: usize,
count: usize
) -> Result<usize, Box<dyn Error>>
Examples
use iostream::io::*; let mut ms= MemoryStream::new(); let data2:[u8;100]=[2;100]; ms.write(&data2,50,50).unwrap();
fn flush(&mut self) -> Result<(), Box<dyn Error>>
[src]
fn copy_to(&mut self, target: &mut dyn Stream) -> Result<(), Box<dyn Error>>
[src]
copy current stream to target stream # Examples ```rust use iostream::io::*; use std::fs::File; Read more
Auto Trait Implementations
impl Send for MemoryStream
impl Sync for MemoryStream
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,