Skip to main content

GenericImage

Enum GenericImage 

Source
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<'_>

Source

pub fn timestamp(&self) -> DateTime<Utc>

The UTC timestamp of the image.

Source

pub fn exposure(&self) -> Duration

The exposure time of the image (Duration::ZERO if not applicable).

Source

pub fn set_exposure(&mut self, exposure: Duration)

Set the exposure time of the image.

Source

pub fn frame_id(&self) -> Option<u32>

The acquisition frame ID of the image, or None if unset.

Source

pub fn set_frame_id(&mut self, frame_id: u32)

Set the acquisition frame ID of the image.

Source

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, a String, or a std::time::Duration or a UTC chrono::DateTime or a tuple of a primitive type and a comment ().
§Valid Types

The valid types for the metadata value are:

§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::Duration or a UTC chrono::DateTime is stored as two consecutive metadata items split into seconds and nanoseconds (keys suffixed _S and _NS), plus a base card.
Source

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.
Source

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, a String, or a std::time::Duration or a UTC chrono::DateTime or 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.
Source

pub fn image(&self) -> DynamicImageView<'_>

A read-only, type-erased DynamicImageView over the samples, whichever half this GenericImage holds.

Source

pub fn metadata(&self) -> &Metadata

Borrow the image’s Metadata.

Source

pub fn metadata_mut(&mut self) -> &mut Metadata

Mutably borrow the image’s Metadata.

Source

pub fn key(&self, name: &str) -> Option<&GenericLineItem>

A specific extra metadata item by name (case-insensitive).

Source

pub fn into_owned(self) -> GenericImageOwned

Convert into an owned GenericImageOwned, copying the samples when this is the borrowed half.

Source§

impl GenericImage<'_>

Source

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<'_>

Source§

fn calc_opt_exp( &mut self, eval: &OptimumExposure, exposure: Duration, bin: u16, ) -> Result<OptimumExposureResult, ExposureError>

Calculate the optimum exposure and binning. Read more
Source§

impl Clone for GenericImage<'_>

Source§

fn clone(&self) -> GenericImage<'_>

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<'a> Debug for GenericImage<'a>

Source§

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

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

impl FitsWrite for GenericImage<'_>

Source§

fn write_fits<P, C>( &self, path: P, compress: C, overwrite: bool, ) -> Result<PathBuf, FitsError>
where P: AsRef<Path>, C: Into<FitsCompression>,

Write the image to path (created, or truncated if overwrite). Returns path.
Source§

fn write_fits_to<W, C>(&self, sink: W, compress: C) -> Result<(), FitsError>
where W: Write, C: Into<FitsCompression>,

Write the image to any Write sink (no filesystem needed).
Source§

fn append_fits<W>(&self, writer: &mut FitsWriter<W>) -> Result<(), FitsError>
where W: Write,

Append the image as a new HDU of an open FitsWriter (file- or memory-backed).
Source§

fn fits_bytes<C>(&self, compress: C) -> Result<Vec<u8>, FitsError>

Serialise the image to an in-memory FITS file.
Source§

impl From<GenericImageOwned> for GenericImage<'_>

Source§

fn from(img: GenericImageOwned) -> GenericImage<'_>

Converts to this type from the input type.
Source§

impl<'a> From<GenericImageRef<'a>> for GenericImage<'a>

Source§

fn from(img: GenericImageRef<'a>) -> GenericImage<'a>

Converts to this type from the input type.
Source§

impl ImageProps for GenericImage<'_>

Source§

fn width(&self) -> usize

Get the width of the image.
Source§

fn height(&self) -> usize

Get the height of the image.
Source§

fn channels(&self) -> u8

Get the number of channels in the image.
Source§

fn color_space(&self) -> ColorSpace

Get the color space of the image.
Source§

fn pixel_type(&self) -> PixelType

Get the pixel type of the image.
Source§

fn len(&self) -> usize

Get the length of the image data.
Source§

fn is_empty(&self) -> bool

Check if the data is empty.
Source§

impl<'a> PartialEq for GenericImage<'a>

Source§

fn eq(&self, other: &GenericImage<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PixelData for GenericImage<'_>

Source§

fn as_raw_u8(&self) -> &[u8]

The whole sample buffer reinterpreted as bytes (native endianness).
Source§

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]>

The samples as &[u8], or None unless the element type is u8.
Source§

fn as_mut_slice_u8(&mut self) -> Option<&mut [u8]>

The samples as &mut [u8], or None unless the element type is u8.
Source§

fn as_slice_u16(&self) -> Option<&[u16]>

The samples as &[u16], or None unless the element type is u16.
Source§

fn as_mut_slice_u16(&mut self) -> Option<&mut [u16]>

The samples as &mut [u16], or None unless the element type is u16.
Source§

fn as_slice_f32(&self) -> Option<&[f32]>

The samples as &[f32], or None unless the element type is f32.
Source§

fn as_mut_slice_f32(&mut self) -> Option<&mut [f32]>

The samples as &mut [f32], or None unless the element type is f32.
Source§

impl<'a> Serialize for GenericImage<'a>

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> StructuralPartialEq for GenericImage<'a>

Source§

impl<'a> TryInto<GenericImageRef<'a>> for GenericImage<'a>

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<GenericImageRef<'a>, <GenericImage<'a> as TryInto<GenericImageRef<'a>>>::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for GenericImage<'a>

§

impl<'a> Freeze for GenericImage<'a>

§

impl<'a> RefUnwindSafe for GenericImage<'a>

§

impl<'a> Send for GenericImage<'a>

§

impl<'a> Sync for GenericImage<'a>

§

impl<'a> Unpin for GenericImage<'a>

§

impl<'a> UnsafeUnpin for GenericImage<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V