pub struct Builder { /* private fields */ }Expand description
Builds a container.
use iris_format::{Builder, Container, SectionKind};
let mut builder = Builder::new("readings", 3);
let data = builder.section(SectionKind::Data, b"three rows go here".to_vec());
let bytes = builder.build()?;
let container = Container::parse(&bytes)?;
container.verify()?;
assert_eq!(container.dataset().rows, 3);
assert_eq!(
container.section_bytes(container.section(data).unwrap()),
b"three rows go here"
);Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new(name: impl Into<String>, rows: u64) -> Self
pub fn new(name: impl Into<String>, rows: u64) -> Self
Starts a container for a dataset with this name and this many rows.
Sourcepub fn schema(
&mut self,
encoding: SchemaEncoding,
bytes: impl Into<Vec<u8>>,
) -> &mut Self
pub fn schema( &mut self, encoding: SchemaEncoding, bytes: impl Into<Vec<u8>>, ) -> &mut Self
Sets the schema.
Sourcepub fn section(&mut self, kind: SectionKind, bytes: impl Into<Vec<u8>>) -> u32
pub fn section(&mut self, kind: SectionKind, bytes: impl Into<Vec<u8>>) -> u32
Adds a section and returns the id the rest of the container refers to it by.
Sourcepub fn embed_decoder(
&mut self,
name: impl Into<String>,
abi: (u16, u16),
required: CapabilitySet,
module: impl Into<Vec<u8>>,
) -> u32
pub fn embed_decoder( &mut self, name: impl Into<String>, abi: (u16, u16), required: CapabilitySet, module: impl Into<Vec<u8>>, ) -> u32
Puts a decoder module in the container and points the dataset at it.
Returns the id of the section the module went into, which is worth having for a tool that wants to print the layout.
Sourcepub fn external_decoder(
&mut self,
name: impl Into<String>,
abi: (u16, u16),
required: CapabilitySet,
digest: Digest,
) -> &mut Self
pub fn external_decoder( &mut self, name: impl Into<String>, abi: (u16, u16), required: CapabilitySet, digest: Digest, ) -> &mut Self
Points the dataset at a decoder that lives somewhere else, named by its digest.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl UnwindSafe for Builder
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