pub struct Writer { /* private fields */ }Expand description
Builds a monolithic XISF file.
Implementations§
Source§impl Writer
impl Writer
pub fn new() -> Writer
Sourcepub fn with_creator(self, creator: impl Into<String>) -> Writer
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.
Sourcepub fn with_creation_time(self, instant: impl Into<String>) -> Writer
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.
Sourcepub fn add_metadata(
&mut self,
id: impl Into<String>,
value: impl Into<String>,
) -> Result<(), Error>
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.
Sourcepub fn add_scalar_property(
&mut self,
id: impl Into<String>,
value: ScalarProperty,
) -> Result<(), Error>
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.
Sourcepub fn add_table(&mut self, table: Table) -> Result<(), Error>
pub fn add_table(&mut self, table: Table) -> Result<(), Error>
Add a table property describing the unit as a whole.
Sourcepub fn add_image(&mut self, pending: PendingImage) -> Result<(), Error>
pub fn add_image(&mut self, pending: PendingImage) -> Result<(), Error>
Add an image, checking that its data matches the geometry it declares.
Sourcepub fn to_distributed(
&self,
blocks_file_name: &str,
) -> Result<DistributedUnit, Error>
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.