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: bgzf_file: file we are trying to read block_tree: indexes of the each block 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: u64current_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.

Examples

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

Examples

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

Examples

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

Examples

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.