Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Integer {
        value: i64,
        comment: Option<String>,
    },
    Float {
        value: f64,
        comment: Option<String>,
    },
    Logical {
        value: bool,
        comment: Option<String>,
    },
    String {
        value: String,
        comment: Option<String>,
    },
    Undefined,
    Invalid(String),
}
Expand description

The value a header card carries, with the comment written beside it.

FITS gives a card one of four kinds of value — an integer, a floating point number, a logical T/F, or a quoted string — or no value at all. Build one from the Rust type it corresponds to and hand it to Header::set_card:

let mut header = Header::default();
header.set_card("FILTER", "Halpha")?;
header.set_card("GAIN", Value::from(1.5).with_comment("e-/ADU"))?;

Variants§

§

Integer

A whole number, written right-justified against column 30.

Fields

§value: i64

The number itself.

§comment: Option<String>

The comment after the value, if the card carried one.

§

Float

A floating point number, written right-justified against column 30.

Fields

§value: f64

The number itself.

§comment: Option<String>

The comment after the value, if the card carried one.

§

Logical

A logical, written as the single character T or F.

Fields

§value: bool

The truth of it.

§comment: Option<String>

The comment after the value, if the card carried one.

§

String

Text, written in single quotes with any quote inside it doubled.

Fields

§value: String

The text, unquoted and with its doubled quotes read back as one.

§comment: Option<String>

The comment after the value, if the card carried one.

§

Undefined

A keyword written with an empty value field, which the standard allows.

§

Invalid(String)

A value field this crate could not read, kept as the text it held so that nothing is lost.

Implementations§

Source§

impl Value

Source

pub fn comment_to_string(&self) -> String

The comment beside this value, or an empty string where there is none.

Source

pub fn value_to_string(&self) -> String

This value as the text a card writes it as, without its quotes.

An undefined or unreadable value has no text, and comes back empty.

Source§

impl Value

The comment on a value, replaced rather than merged.

Source

pub fn with_comment(self, comment: impl Into<String>) -> Self

This value carrying comment beside it.

A comment on an Value::Undefined or Value::Invalid value has nowhere to live and is dropped: neither of them is written with a value field for a comment to follow.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

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 Debug for Value

Source§

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

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

impl From<&String> for Value

Source§

fn from(value: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value>> From<Option<T>> for Value

An absent value is an undefined one: the keyword is written with an empty value field, which is how FITS spells “this card has no value”.

Source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Value

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, <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.