Trait seq_io::BufPolicy[][src]

pub trait BufPolicy {
    fn grow_to(&mut self, current_size: usize) -> Option<usize>;
}

Policy that decides how a buffer should grow

Returns the number of additional bytes given the current size. Returning None instead will indicate that the buffer has grown too big. Creates a new reader with a given buffer capacity and growth policy

Example

use seq_io::BufPolicy;
use seq_io::fasta::{Reader,Record};
use std::io::stdin;

struct Max1G;

// This policy limits the buffer size to 1 GB
impl BufPolicy for Max1G {
    fn grow_to(&mut self, current_size: usize) -> Option<usize> {
        if current_size > 1 << 30 {
            return None
        }
        Some(current_size * 2)
    }
}

let mut reader = Reader::new(stdin()).set_policy(Max1G);

while let Some(record) = reader.next() {
    println!("{}", record.unwrap().id().unwrap());
}

Required Methods

Implementors