pub struct Writer<W>where
W: Write,{ /* private fields */ }Expand description
A Fasta writer.
Implementations§
Source§impl<W> Writer<W>where
W: Write,
impl<W> Writer<W>where
W: Write,
Sourcepub fn with_capacity(capacity: usize, writer: W) -> Writer<W>
pub fn with_capacity(capacity: usize, writer: W) -> Writer<W>
Create a new Fasta writer with a capacity of write buffer
Sourcepub fn from_bufwriter(bufwriter: BufWriter<W>) -> Writer<W>
pub fn from_bufwriter(bufwriter: BufWriter<W>) -> Writer<W>
Create a new Fasta writer with a given BufWriter
Sourcepub fn write_record(&mut self, record: &Record) -> Result<(), Error>
pub fn write_record(&mut self, record: &Record) -> Result<(), Error>
Directly write a fasta::Record.
§Errors
If there is an issue writing to the Writer.
§Examples
use bio::io::fasta::{Record, Writer};
use std::fs;
use std::io;
use std::path::Path;
let path = Path::new("test.fa");
let file = fs::File::create(path).unwrap();
{
let handle = io::BufWriter::new(file);
let mut writer = Writer::new(handle);
let record = Record::with_attrs("id", Some("desc"), b"ACGT");
let write_result = writer.write_record(&record);
assert!(write_result.is_ok());
}
let actual = fs::read_to_string(path).unwrap();
let expected = ">id desc\nACGT\n";
assert!(fs::remove_file(path).is_ok());
assert_eq!(actual, expected)Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for Writer<W>where
W: Freeze,
impl<W> RefUnwindSafe for Writer<W>where
W: RefUnwindSafe,
impl<W> Send for Writer<W>where
W: Send,
impl<W> Sync for Writer<W>where
W: Sync,
impl<W> Unpin for Writer<W>where
W: Unpin,
impl<W> UnwindSafe for Writer<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.