Skip to main content

Writer

Struct Writer 

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

Builds a monolithic XISF file.

Implementations§

Source§

impl Writer

Source

pub fn new() -> Writer

Source

pub fn with_creator(self, creator: impl Into<String>) -> Writer

Name the software that produced the file. Written as XISF:CreatorApplication, which is the property the spec reserves.

Source

pub fn with_creation_time(self, instant: impl Into<String>) -> Writer

Set XISF:CreationTime rather than taking it from the clock.

The spec requires the property, so it is always written; this exists because a timestamp makes output non-reproducible, and a caller rebuilding a file or comparing two runs needs to be able to pin it. The value is written as given, so it must be a valid ISO 8601 instant.

Source

pub fn add_metadata( &mut self, id: impl Into<String>, value: impl Into<String>, ) -> Result<(), Error>

Add a string property to the file’s <Metadata>.

The identifier must satisfy the format’s grammar, since a property nothing can look up by name is not a property.

Source

pub fn add_scalar_property( &mut self, id: impl Into<String>, value: ScalarProperty, ) -> Result<(), Error>

Add a scalar property to the file’s <Metadata>.

A baseline encoder must “write properties of all 8-bit, 16-bit, 32-bit and 64-bit scalar types”, and until this existed the only property this writer could emit was a string – so a caller had no way to record an exposure time as a Float32 or a gain as an Int32 without writing the number out as text under a type that says it is text.

The value is serialized as the specification’s plain text for its type, and is checked against the declared type before it is accepted, so a value that does not fit is refused here rather than read back as a different number.

Source

pub fn add_table(&mut self, table: Table) -> Result<(), Error>

Add a table property describing the unit as a whole.

Source

pub fn add_image(&mut self, pending: PendingImage) -> Result<(), Error>

Add an image, checking that its data matches the geometry it declares.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serialise the whole file.

Source

pub fn to_distributed( &self, blocks_file_name: &str, ) -> Result<DistributedUnit, Error>

Serialise as a distributed unit: a header file and a blocks file.

blocks_file_name is what the header will name, so it must be the name the blocks file is actually saved under, and the two must end up in the same directory. The reader resolves a relative locator beside the file that named it.

Unlike the monolithic form this needs no fixed point: the header names blocks by identifier rather than by position, so its length does not feed back into its contents.

Trait Implementations§

Source§

impl Clone for Writer

Source§

fn clone(&self) -> Writer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Writer

Source§

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

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

impl Default for Writer

Source§

fn default() -> Writer

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.