Struct bgzf_rust_reader::BgzfReader [−][src]
pub struct BgzfReader { pub input_length: u64, pub current_read_position: Cell<u64>, pub pos: Cell<u64>, // some fields omitted }
Expand description
Struct to read bgzf file
Fields description:
input_length: total length of the uncompressed version, current_read_position: current position of the compressed file, pos: current position of the uncompressed file,
Fields
input_length: u64
current_read_position: Cell<u64>
pos: Cell<u64>
Implementations
Below are the steps to use the bgzf Reader, 1st step is to create a BGZF instance with a new function after that read, and seek method can be used respectively.
Example
use bgzf_rust_reader::BgzfReader; use std::str; let reader = BgzfReader::new(String::from("bgzf_test.bgz")).unwrap(); let mut vec = vec![0; 52]; let data_read = reader.read_to(&mut vec); assert_eq!(data_read.unwrap(), 52); assert_eq!( "This is just a bgzf test,lets see how it reacts. :).", str::from_utf8(&vec).unwrap() );
This method can set the file position relative to uncompressed data
Example
use bgzf_rust_reader::BgzfReader; let reader = BgzfReader::new(String::from("bgzf_test.bgz")).unwrap(); reader.seek(33); assert_eq!(0, reader.current_read_position.get()); assert_eq!(33, reader.pos.get());
This method calculates total uncompressed length
this method reads data to the slice passed
Example
use bgzf_rust_reader::BgzfReader; use std::str; let reader = BgzfReader::new(String::from("bgzf_test.bgz")).unwrap(); let mut vec = vec![0; 52]; let data_read = reader.read_to(&mut vec); assert_eq!(data_read.unwrap(), 52); assert_eq!( "This is just a bgzf test,lets see how it reacts. :).", str::from_utf8(&vec).unwrap() );
this method reads data to the slice from offset position, up to the len position
Example
use bgzf_rust_reader::BgzfReader; use std::str; let reader = BgzfReader::new(String::from("bgzf_test.bgz")).unwrap(); let mut content = vec![0; 10]; match reader.read(&mut content, 0, 10) { Ok(val) => { assert_eq!(10, val); } Err(e) => { assert!(false); } }; let file_content = str::from_utf8(&content).unwrap(); assert_eq!("This is ju", file_content);
Auto Trait Implementations
impl !RefUnwindSafe for BgzfReader
impl Send for BgzfReader
impl !Sync for BgzfReader
impl Unpin for BgzfReader
impl UnwindSafe for BgzfReader