pub enum SaveFileValue {
String(Rc<str>),
Object(SaveFileObject),
Real(f64),
Integer(i64),
Boolean(bool),
Date(Date),
}
Expand description
A value that comes from a save file. Matching against this enum is a bad idea, because SaveFileValue::String may actually contain any type. It’s better to use the conversion methods like SaveFileValue::as_string.
Variants§
String(Rc<str>)
A simple string value, may be anything in reality.
Object(SaveFileObject)
A complex object value.
Real(f64)
A floating point value
Integer(i64)
An integer
Boolean(bool)
A boolean
Date(Date)
A date
Implementations§
Source§impl SaveFileValue
impl SaveFileValue
Sourcepub fn as_id(&self) -> Result<u32, ConversionError>
pub fn as_id(&self) -> Result<u32, ConversionError>
Get the value as a GameId
Sourcepub fn as_object(&self) -> Result<&SaveFileObject, ConversionError>
pub fn as_object(&self) -> Result<&SaveFileObject, ConversionError>
Get the value as a GameObject
Sourcepub fn as_integer(&self) -> Result<i64, ConversionError>
pub fn as_integer(&self) -> Result<i64, ConversionError>
Get the value as an integer. If the value is a real number, it will be truncated.
Sourcepub fn as_real(&self) -> Result<f64, ConversionError>
pub fn as_real(&self) -> Result<f64, ConversionError>
Get the value as a real number. If the value is an integer, it will be converted to a real number.
Sourcepub fn as_date(&self) -> Result<Date, ConversionError>
pub fn as_date(&self) -> Result<Date, ConversionError>
Get the value as a date
Sourcepub fn as_boolean(&self) -> Result<bool, ConversionError>
pub fn as_boolean(&self) -> Result<bool, ConversionError>
Get the value as a boolean
Trait Implementations§
Source§impl Clone for SaveFileValue
impl Clone for SaveFileValue
Source§fn clone(&self) -> SaveFileValue
fn clone(&self) -> SaveFileValue
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 Debug for SaveFileValue
impl Debug for SaveFileValue
Source§impl From<&str> for SaveFileValue
impl From<&str> for SaveFileValue
Source§impl From<Date> for SaveFileValue
impl From<Date> for SaveFileValue
Source§impl From<SaveFileObject> for SaveFileValue
impl From<SaveFileObject> for SaveFileValue
Source§fn from(value: SaveFileObject) -> Self
fn from(value: SaveFileObject) -> Self
Converts to this type from the input type.
Source§impl From<String> for SaveFileValue
impl From<String> for SaveFileValue
Source§impl From<bool> for SaveFileValue
impl From<bool> for SaveFileValue
Source§impl From<f64> for SaveFileValue
impl From<f64> for SaveFileValue
Source§impl From<i32> for SaveFileValue
impl From<i32> for SaveFileValue
Source§impl From<i64> for SaveFileValue
impl From<i64> for SaveFileValue
Source§impl From<u32> for SaveFileValue
impl From<u32> for SaveFileValue
Source§impl From<u64> for SaveFileValue
impl From<u64> for SaveFileValue
Source§impl PartialEq for SaveFileValue
impl PartialEq for SaveFileValue
Source§impl TryInto<String> for SaveFileValue
impl TryInto<String> for SaveFileValue
impl StructuralPartialEq for SaveFileValue
Auto Trait Implementations§
impl Freeze for SaveFileValue
impl RefUnwindSafe for SaveFileValue
impl !Send for SaveFileValue
impl !Sync for SaveFileValue
impl Unpin for SaveFileValue
impl UnwindSafe for SaveFileValue
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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