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 get_timestamp(&self) -> SystemTime
pub fn get_timestamp(&self) -> SystemTime
Get the timestamp of the image.
sourcepub fn get_exposure(&self) -> Option<Duration>
pub fn get_exposure(&self) -> Option<Duration>
Get the exposure time of the image.
sourcepub fn insert_key<T>(
&mut self,
name: &str,
value: T,
) -> Result<(), &'static str>where
T: InsertValue,
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, aString
, or astd::time::Duration
orstd::time::SystemTime
or a tuple of a primitive type and a comment ().
§Valid Types
The valid types for the metadata value are:
u8
|u16
|u32
|u64
i8
|i16
|i32
|i64
f32
|f64
ColorSpace
std::time::Duration
|std::time::SystemTime
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::Duration
orstd::time::SystemTime
is split and stored as two consecutive metadata items, with the same key, split into seconds (u64
) and nanoseconds (u64
).
sourcepub fn remove_key(&mut self, name: &str) -> Result<(), &'static str>
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.
sourcepub fn replace_key<T>(
&mut self,
name: &str,
value: T,
) -> Result<(), &'static str>where
T: InsertValue,
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, aString
, or astd::time::Duration
orstd::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.
sourcepub fn get_metadata(&self) -> &HashMap<String, GenericLineItem>
pub fn get_metadata(&self) -> &HashMap<String, GenericLineItem>
Get the contained metadata as a slice of GenericLineItem
s.
§Returns
A slice of GenericLineItem
s containing the metadata.
source§impl<'a, 'b> GenericImage<'a>where
'a: 'b,
impl<'a, 'b> GenericImage<'a>where
'a: 'b,
sourcepub fn debayer(
&'a self,
method: DemosaicMethod,
) -> Result<GenericImage<'b>, BayerError>
pub fn debayer( &'a self, method: DemosaicMethod, ) -> Result<GenericImage<'b>, BayerError>
Debayer a GenericImage
using the specified algorithm.
source§impl GenericImage<'_>
impl GenericImage<'_>
sourcepub fn as_raw_u8(&self) -> &[u8] ⓘ
pub fn as_raw_u8(&self) -> &[u8] ⓘ
Get the data as a slice of u8
, regardless of the underlying type.
sourcepub fn as_raw_u8_checked(&self) -> Option<&[u8]>
pub fn as_raw_u8_checked(&self) -> Option<&[u8]>
Get the data as a slice of u8
, regardless of the underlying type.
sourcepub fn as_slice_u8(&self) -> Option<&[u8]>
pub fn as_slice_u8(&self) -> Option<&[u8]>
sourcepub fn as_mut_slice_u8(&mut self) -> Option<&mut [u8]>
pub fn as_mut_slice_u8(&mut self) -> Option<&mut [u8]>
sourcepub fn as_slice_u16(&self) -> Option<&[u16]>
pub fn as_slice_u16(&self) -> Option<&[u16]>
sourcepub fn as_mut_slice_u16(&mut self) -> Option<&mut [u16]>
pub fn as_mut_slice_u16(&mut self) -> Option<&mut [u16]>
sourcepub fn as_slice_f32(&self) -> Option<&[f32]>
pub fn as_slice_f32(&self) -> Option<&[f32]>
Trait Implementations§
source§impl CalcOptExp for GenericImage<'_>
impl CalcOptExp for GenericImage<'_>
source§impl Clone for GenericImage<'_>
impl Clone for GenericImage<'_>
source§fn clone(&self) -> GenericImage<'_>
fn clone(&self) -> GenericImage<'_>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a> Debug for GenericImage<'a>
impl<'a> Debug for GenericImage<'a>
source§impl From<GenericImageOwned> for GenericImage<'_>
impl From<GenericImageOwned> for GenericImage<'_>
source§fn from(img: GenericImageOwned) -> GenericImage<'_>
fn from(img: GenericImageOwned) -> GenericImage<'_>
Converts to this type from the input type.
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>
Converts to this type from the input type.
source§impl ImageProps for GenericImage<'_>
impl ImageProps for GenericImage<'_>
source§type OutputU8 = GenericImageOwned
type OutputU8 = GenericImageOwned
The output type of
ImageProps::cast_u8
.source§fn color_space(&self) -> ColorSpace
fn color_space(&self) -> ColorSpace
Get the color space of the image.
source§fn pixel_type(&self) -> PixelType
fn pixel_type(&self) -> PixelType
Get the pixel type of the image.
source§fn cast_u8(&self) -> <GenericImage<'_> as ImageProps>::OutputU8
fn cast_u8(&self) -> <GenericImage<'_> as ImageProps>::OutputU8
Convert the image to a
u8
image. Read moresource§impl<'a> PartialEq for GenericImage<'a>
impl<'a> PartialEq for GenericImage<'a>
source§impl<'a> Serialize for GenericImage<'a>
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,
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<'_>
impl ToLuma for GenericImage<'_>
source§impl<'a> TryInto<GenericImageRef<'a>> for GenericImage<'a>
impl<'a> TryInto<GenericImageRef<'a>> for GenericImage<'a>
source§fn try_into(
self,
) -> Result<GenericImageRef<'a>, <GenericImage<'a> as TryInto<GenericImageRef<'a>>>::Error>
fn try_into( self, ) -> Result<GenericImageRef<'a>, <GenericImage<'a> as TryInto<GenericImageRef<'a>>>::Error>
Performs the conversion.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)