Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

A builder for a Section.

Implementations§

Source§

impl Builder

Source

pub fn header(self, record: Record) -> Result<Self, Error>

Sets the header record for the Builder.

§Examples
use chainfile::alignment::section::Builder;
use chainfile::alignment::section::header::Record;

let header = "chain 0 seq0 2 + 0 2 seq0 2 - 0 2 1".parse::<Record>()?;
let builder = Builder::default().header(header)?;
Source

pub fn push_data(self, record: Record) -> Self

Pushes a data record into the Builder.

§Examples
use chainfile::alignment::section::Builder;
use chainfile::alignment::section::data::Record;

let data = "10".parse::<Record>()?;
let builder = Builder::default().push_data(data);
Source

pub fn try_build(self) -> Result<Section, Error>

Consumes self to attempt to build a Section.

§Examples
use chainfile::alignment::section::Builder;
use chainfile::alignment::section::data;
use chainfile::alignment::section::header;

let mut section = Builder::default()
    .header("chain 0 seq0 2 + 0 2 seq0 2 - 0 2 1".parse()?)?
    .push_data("3\t0\t1".parse()?)
    .push_data("1".parse()?)
    .try_build()?;

assert_eq!(section.header().score(), 0);
assert_eq!(section.header().id(), 1);
assert_eq!(section.data().len(), 2);

Trait Implementations§

Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.