generic_camera

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 get_timestamp(&self) -> SystemTime

Get the timestamp of the image.

source

pub fn get_exposure(&self) -> Option<Duration>

Get the exposure time of the image.

source

pub fn insert_key<T>( &mut self, name: &str, value: T, ) -> Result<(), &'static str>
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 std::time::SystemTime 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 std::time::SystemTime is split and stored as two consecutive metadata items, with the same key, split into seconds (u64) and nanoseconds (u64).
source

pub fn remove_key(&mut self, name: &str) -> Result<(), &'static str>

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<(), &'static str>
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 std::time::SystemTime 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 get_metadata(&self) -> &HashMap<String, GenericLineItem>

Get the contained metadata as a slice of GenericLineItems.

§Returns

A slice of GenericLineItems containing the metadata.

source

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

Get a specific metadata value by name.

Returns the first metadata value with the given name.

§Arguments
  • name: The name of the metadata value.
source§

impl<'a, 'b> GenericImage<'a>
where 'a: 'b,

source

pub fn debayer( &'a self, method: DemosaicMethod, ) -> Result<GenericImage<'b>, BayerError>

Debayer a GenericImage using the specified algorithm.

source§

impl GenericImage<'_>

source

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

Get the data as a slice of u8, regardless of the underlying type.

source

pub fn as_raw_u8_checked(&self) -> Option<&[u8]>

Get the data as a slice of u8, regardless of the underlying type.

source

pub fn as_slice_u8(&self) -> Option<&[u8]>

Get the data as a slice of u8.

§Note

The returned slice may not be the same length as the image. Use len to get the length of the image.

source

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

Get the data as a mutable slice of u8.

§Note

The returned slice may not be the same length as the image. Use len to get the length of the image.

source

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

Get the data as a slice of u16.

§Note

The returned slice may not be the same length as the image. Use len to get the length of the image.

source

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

Get the data as a mutable slice of u16.

§Note

The returned slice may not be the same length as the image. Use len to get the length of the image.

source

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

Get the data as a slice of f32.

§Note

The returned slice may not be the same length as the image. Use len to get the length of the image.

source

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

Get the data as a mutable slice of f32.

§Note

The returned slice may not be the same length as the image. Use len to get the length of the image.

Trait Implementations§

source§

impl CalcOptExp for GenericImage<'_>

source§

fn calc_opt_exp( self, eval: &OptimumExposure, exposure: Duration, bin: u8, ) -> Result<(Duration, u16), &'static str>

Calculate the optimum exposure time and binning. Read more
source§

impl Clone for GenericImage<'_>

source§

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

Returns a copy of the value. Read more
1.0.0 · 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 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§

type OutputU8 = GenericImageOwned

The output type of ImageProps::cast_u8.
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§

fn cast_u8(&self) -> <GenericImage<'_> as ImageProps>::OutputU8

Convert the image to a u8 image. Read more
source§

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

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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 ToLuma for GenericImage<'_>

source§

fn to_luma(&mut self) -> Result<(), &'static str>

Convert the image to a luminance image. Read more
source§

fn to_luma_custom(&mut self, coeffs: &[f64]) -> Result<(), &'static str>

Convert the image to a luminance image with custom coefficients. Read more
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.
source§

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

Auto Trait Implementations§

§

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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