pub enum GenericImage<'a> {
Ref(GenericImageRef<'a>),
Own(GenericImageOwned),
}Expand description
A serializable, generic image with metadata, backed by either
a GenericImageRef or a GenericImageOwned.
Variants§
Implementations§
Source§impl GenericImage<'_>
impl GenericImage<'_>
Sourcepub fn exposure(&self) -> Duration
pub fn exposure(&self) -> Duration
The exposure time of the image (Duration::ZERO if not applicable).
Sourcepub fn set_exposure(&mut self, exposure: Duration)
pub fn set_exposure(&mut self, exposure: Duration)
Set the exposure time of the image.
Sourcepub fn set_frame_id(&mut self, frame_id: u32)
pub fn set_frame_id(&mut self, frame_id: u32)
Set the acquisition frame ID of the image.
Sourcepub fn insert_key<T>(
&mut self,
name: &str,
value: T,
) -> Result<(), MetadataError>where
T: InsertValue,
pub fn insert_key<T>(
&mut self,
name: &str,
value: T,
) -> Result<(), MetadataError>where
T: InsertValue,
Insert a metadata value into the GenericImage.
§Arguments
name: The name of the metadata value. The name must be non-empty and less than 80 characters.value: The value to insert. The value is either a primitive type, aString, or astd::time::Durationor a UTCchrono::DateTimeor a tuple of a primitive type and a comment ().
§Valid Types
The valid types for the metadata value are:
u8|u16|u32|u64i8|i16|i32|i64f32|f64ColorSpacestd::time::Duration|chrono::DateTime<Utc>String|&str
§Note
- The metadata key is case-insensitive and is stored as an uppercase string.
- Re-inserting a timestamp key will return an error.
- When saving to a FITS file, the metadata comment may be truncated.
- Metadata of type
std::time::Durationor a UTCchrono::DateTimeis stored as two consecutive metadata items split into seconds and nanoseconds (keys suffixed_Sand_NS), plus a base card.
Sourcepub fn remove_key(
&mut self,
name: &str,
) -> Result<GenericLineItem, MetadataError>
pub fn remove_key( &mut self, name: &str, ) -> Result<GenericLineItem, MetadataError>
Remove a metadata value from the GenericImageOwned.
§Arguments
name: The name of the metadata value to remove.
§Returns
Ok(())if the key was removed successfully.Err("Can not remove timestamp key")if the key is the timestamp key.Err("Key not found")if the key was not found.Err("Key cannot be empty")if the key is an empty string.Err("Key cannot be longer than 80 characters")if the key is longer than 80 characters.
Sourcepub fn replace_key<T>(
&mut self,
name: &str,
value: T,
) -> Result<GenericLineItem, MetadataError>where
T: InsertValue,
pub fn replace_key<T>(
&mut self,
name: &str,
value: T,
) -> Result<GenericLineItem, MetadataError>where
T: InsertValue,
Replace a metadata value in the GenericImageOwned.
§Arguments
name: The name of the metadata value to replace.value: The new value to insert. The value is either a primitive type, aString, or astd::time::Durationor a UTCchrono::DateTimeor a tuple of a value type and a comment.
§Returns
Ok(())if the key was replaced successfully.Err("Key not found")if the key was not found.
Sourcepub fn image(&self) -> DynamicImageView<'_>
pub fn image(&self) -> DynamicImageView<'_>
A read-only, type-erased DynamicImageView over the samples, whichever
half this GenericImage holds.
Sourcepub fn metadata_mut(&mut self) -> &mut Metadata
pub fn metadata_mut(&mut self) -> &mut Metadata
Mutably borrow the image’s Metadata.
Sourcepub fn key(&self, name: &str) -> Option<&GenericLineItem>
pub fn key(&self, name: &str) -> Option<&GenericLineItem>
A specific extra metadata item by name (case-insensitive).
Sourcepub fn into_owned(self) -> GenericImageOwned
pub fn into_owned(self) -> GenericImageOwned
Convert into an owned GenericImageOwned, copying the samples when this
is the borrowed half.
Source§impl GenericImage<'_>
impl GenericImage<'_>
Sourcepub fn optimum_exposure(
&mut self,
eval: &OptimumExposure,
bin: u16,
) -> Result<OptimumExposureResult, ExposureError>
pub fn optimum_exposure( &mut self, eval: &OptimumExposure, bin: u16, ) -> Result<OptimumExposureResult, ExposureError>
Optimum exposure and binning, using this image’s own recorded
exposure.
§Errors
ExposureError::ZeroExposure if the
recorded exposure is Duration::ZERO, otherwise see
ExposureError.
Trait Implementations§
Source§impl CalcOptExp for GenericImage<'_>
impl CalcOptExp for GenericImage<'_>
Source§fn calc_opt_exp(
&mut self,
eval: &OptimumExposure,
exposure: Duration,
bin: u16,
) -> Result<OptimumExposureResult, ExposureError>
fn calc_opt_exp( &mut self, eval: &OptimumExposure, exposure: Duration, bin: u16, ) -> Result<OptimumExposureResult, ExposureError>
Source§impl Clone for GenericImage<'_>
impl Clone for GenericImage<'_>
Source§fn clone(&self) -> GenericImage<'_>
fn clone(&self) -> GenericImage<'_>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for GenericImage<'a>
impl<'a> Debug for GenericImage<'a>
Source§impl FitsWrite for GenericImage<'_>
impl FitsWrite for GenericImage<'_>
Source§fn write_fits<P, C>(
&self,
path: P,
compress: C,
overwrite: bool,
) -> Result<PathBuf, FitsError>
fn write_fits<P, C>( &self, path: P, compress: C, overwrite: bool, ) -> Result<PathBuf, FitsError>
path (created, or truncated if overwrite). Returns path.Source§fn write_fits_to<W, C>(&self, sink: W, compress: C) -> Result<(), FitsError>
fn write_fits_to<W, C>(&self, sink: W, compress: C) -> Result<(), FitsError>
Write sink (no filesystem needed).Source§fn append_fits<W>(&self, writer: &mut FitsWriter<W>) -> Result<(), FitsError>where
W: Write,
fn append_fits<W>(&self, writer: &mut FitsWriter<W>) -> Result<(), FitsError>where
W: Write,
FitsWriter (file- or memory-backed).Source§fn fits_bytes<C>(&self, compress: C) -> Result<Vec<u8>, FitsError>where
C: Into<FitsCompression>,
fn fits_bytes<C>(&self, compress: C) -> Result<Vec<u8>, FitsError>where
C: Into<FitsCompression>,
Source§impl From<GenericImageOwned> for GenericImage<'_>
impl From<GenericImageOwned> for GenericImage<'_>
Source§fn from(img: GenericImageOwned) -> GenericImage<'_>
fn from(img: GenericImageOwned) -> GenericImage<'_>
Source§impl<'a> From<GenericImageRef<'a>> for GenericImage<'a>
impl<'a> From<GenericImageRef<'a>> for GenericImage<'a>
Source§fn from(img: GenericImageRef<'a>) -> GenericImage<'a>
fn from(img: GenericImageRef<'a>) -> GenericImage<'a>
Source§impl ImageProps for GenericImage<'_>
impl ImageProps for GenericImage<'_>
Source§fn color_space(&self) -> ColorSpace
fn color_space(&self) -> ColorSpace
Source§fn pixel_type(&self) -> PixelType
fn pixel_type(&self) -> PixelType
Source§impl<'a> PartialEq for GenericImage<'a>
impl<'a> PartialEq for GenericImage<'a>
Source§impl PixelData for GenericImage<'_>
impl PixelData for GenericImage<'_>
Source§fn as_raw_u8(&self) -> &[u8] ⓘ
fn as_raw_u8(&self) -> &[u8] ⓘ
Source§fn as_raw_u8_checked(&self) -> Option<&[u8]>
fn as_raw_u8_checked(&self) -> Option<&[u8]>
as_raw_u8, but None on a reinterpret-cast failure
instead of panicking.Source§fn as_slice_u8(&self) -> Option<&[u8]>
fn as_slice_u8(&self) -> Option<&[u8]>
&[u8], or None unless the element type is u8.Source§fn as_mut_slice_u8(&mut self) -> Option<&mut [u8]>
fn as_mut_slice_u8(&mut self) -> Option<&mut [u8]>
&mut [u8], or None unless the element type is u8.Source§fn as_slice_u16(&self) -> Option<&[u16]>
fn as_slice_u16(&self) -> Option<&[u16]>
&[u16], or None unless the element type is u16.Source§fn as_mut_slice_u16(&mut self) -> Option<&mut [u16]>
fn as_mut_slice_u16(&mut self) -> Option<&mut [u16]>
&mut [u16], or None unless the element type is u16.Source§fn as_slice_f32(&self) -> Option<&[f32]>
fn as_slice_f32(&self) -> Option<&[f32]>
&[f32], or None unless the element type is f32.Source§fn as_mut_slice_f32(&mut self) -> Option<&mut [f32]>
fn as_mut_slice_f32(&mut self) -> Option<&mut [f32]>
&mut [f32], or None unless the element type is f32.