pub enum KOSValue {
Show 13 variants Null, Bool(bool), Byte(i8), Int16(i16), Int32(i32), Float(f32), Double(f64), String(String), ArgMarker, ScalarInt(i32), ScalarDouble(f64), BoolValue(bool), StringValue(String),
}
Expand description

An internal value within Kerbal Operating System.

These are documented within the GitHub repo’s KSM Docs. These are used as operands to instructions and stored in the KO file’s data section, and a KSM file’s argument section.

Each value takes up 1 byte just for the “data type” so that kOS knows how to load the value.

The “Value” types (ScalarInt, ScalarDouble, BoolValue, StringValue) are different from their non-value counterparts in that the “Value” types have more built-in suffixes, and are the type used when there are any user-created values, as opposed to instruction operands. See KSM docs for more information.

Variants§

§

Null

A null value, rarely used. Only takes up 1 byte.

§

Bool(bool)

A boolean. Takes up 2 bytes.

§

Byte(i8)

A signed byte. Takes up 2 bytes.

§

Int16(i16)

A signed 16-bit integer. Takes up 3 bytes.

§

Int32(i32)

A signed 32-bit integer. Takes up 5 bytes.

§

Float(f32)

A 32-bit floating point number. Takes up 5 bytes.

§

Double(f64)

A 64-bit floating point number. Takes up 9 bytes.

§

String(String)

A string. Takes up 2 + length bytes.

§

ArgMarker

An argument marker. Takes up 1 byte.

§

ScalarInt(i32)

A signed 32-bit integer. Takes up 5 bytes.

§

ScalarDouble(f64)

A 64-bit floating point number. Takes up 9 bytes.

§

BoolValue(bool)

A boolean. Takes up 2 bytes.

§

StringValue(String)

A string. Takes up 2 + length bytes.

Implementations§

source§

impl KOSValue

source

pub fn size_bytes(&self) -> usize

Returns the size of the value in bytes.

Trait Implementations§

source§

impl Clone for KOSValue

source§

fn clone(&self) -> KOSValue

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

source§

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

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

impl FromBytes for KOSValue

§

type Error = KOSValueParseError

The error type returned when the conversion fails
source§

fn from_bytes(source: &mut BufferIterator<'_>) -> Result<Self, Self::Error>where Self: Sized,

Parses a value from the buffer iterator.
source§

impl Hash for KOSValue

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<KOSValue> for KOSValue

source§

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

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

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToBytes for KOSValue

source§

fn to_bytes(&self, buf: &mut impl WritableBuffer)

Converts a type into bytes and appends it to the buffer.
source§

impl Eq for KOSValue

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.