Skip to main content

FuelPrice

Struct FuelPrice 

Source
pub struct FuelPrice {
    pub fuel_type: Option<FuelType>,
    pub price: Money,
    pub update_time: Timestamp,
}
Expand description

Fuel price information for a given type of fuel at a gas station.

Fuel prices provide current pricing information for specific fuel types, helping drivers compare costs across different stations and fuel grades.

Prices include timestamp information to indicate freshness and reliability of the pricing data. This information is updated regularly to reflect current market conditions.

Fields§

§fuel_type: Option<FuelType>

The type of fuel this price represents.

Specifies the exact fuel grade or type (regular, premium, diesel, etc.) that this pricing information applies to. Different fuel types at the same station will have separate FuelPrice entries.

§price: Money

The price of the fuel.

Current price per unit (typically per gallon or liter depending on region) for this specific fuel type. Includes currency information for international compatibility and precise monetary representation.

§update_time: Timestamp

The time when this fuel price was last updated.

Timestamp indicating when this price information was last verified or updated. More recent timestamps indicate more reliable pricing data, which is crucial for fuel price comparisons and decision-making.

Implementations§

Source§

impl FuelPrice

Source

pub fn price(&self) -> &Money

The price of the fuel.

Current price per unit (typically per gallon or liter depending on region) for this specific fuel type. Includes currency information for international compatibility and precise monetary representation.

Source§

impl FuelPrice

Source

pub fn fuel_type(&self) -> Option<FuelType>

The type of fuel this price represents.

Specifies the exact fuel grade or type (regular, premium, diesel, etc.) that this pricing information applies to. Different fuel types at the same station will have separate FuelPrice entries.

Source

pub fn update_time(&self) -> Timestamp

The time when this fuel price was last updated.

Timestamp indicating when this price information was last verified or updated. More recent timestamps indicate more reliable pricing data, which is crucial for fuel price comparisons and decision-making.

Source§

impl FuelPrice

Source

pub const fn new( fuel_type: Option<FuelType>, price: Money, update_time: Timestamp, ) -> Self

Creates a new FuelPrice with the specified fuel type, price, and update time.

Used to construct fuel price information with all essential components. The update time should reflect when the price was last verified to ensure data freshness and reliability for users.

Source

pub fn with_current_time(fuel_type: Option<FuelType>, price: Money) -> Self

Creates a FuelPrice with current timestamp.

Convenience constructor that automatically sets the update time to now, useful when recording fresh price data from gas station APIs or manual input.

Source

pub fn age(&self) -> Result<Span, Error>

Returns the age of this price information.

Calculates how long ago this price was last updated, useful for determining data freshness and reliability. Older prices may be less accurate due to market fluctuations and should be used with caution.

Source

pub fn is_very_recent(&self) -> Result<bool, Error>

Returns whether this price information is very recent.

Used to identify the most current and reliable price data, typically updated within the last few hours for optimal accuracy.

Source

pub fn is_fresh(&self) -> Result<bool, Error>

Returns whether this price information is considered fresh.

Used to determine if the price data is recent enough to be reliable for user decision-making. Fuel prices can change frequently, so freshness is important for accurate comparisons.

Source

pub fn is_stale(&self) -> Result<bool, Error>

Returns whether this price information is stale.

Used to identify outdated price data that may not reflect current market conditions. Stale prices should be updated or marked as potentially inaccurate in user interfaces.

Source

pub fn update_time_description(&self) -> Result<String, Error>

Gets a user-friendly description of when this price was last updated.

Provides relative time descriptions like “2 hours ago” or “yesterday” that help users understand the freshness of price information.

Source

pub fn freshness_indicator(&self) -> Result<FreshnessIndicator, Error>

Returns a freshness indicator for display purposes.

Provides a simple classification of price data freshness that can be used for color coding, badges, or user interface indicators.

Source

pub fn formatted_price(&self) -> String

Gets the price per unit with currency formatting.

Returns a formatted price string suitable for display in gas station listings, price comparison interfaces, and mobile applications.

Source

pub fn compact_price(&self) -> String

Gets a compact price representation for mobile displays.

Provides space-efficient price formatting suitable for mobile interfaces, map overlays, or anywhere screen real estate is limited.

Source

pub fn is_competitive(&self, average_price: Option<&Money>) -> bool

Returns whether this fuel price represents a competitive rate.

Used to identify notably good prices for highlighting in user interfaces. This is a placeholder implementation that could be enhanced with market data for more accurate competitive analysis.

Source

pub fn fuel_type_name(&self) -> String

Gets a display-friendly fuel type name.

Returns the human-readable name of the fuel type for user interfaces. If the fuel type is unknown, returns a generic description.

Source

pub fn full_description(&self) -> String

Creates a full description combining fuel type and price.

Provides complete information suitable for detailed listings, tooltips, or comprehensive price displays that include both fuel type and cost.

Source

pub fn has_valid_price(&self) -> bool

Returns whether this price has valid monetary information.

Used to validate price data before displaying or using it for comparisons, ensuring the price contains meaningful and properly formatted monetary values.

Source

pub fn compare_price(&self, other: &Self) -> Option<Ordering>

Compares this price with another for the same fuel type.

Provides price comparison functionality for sorting and filtering operations. Only meaningful when comparing prices for the same fuel type and currency.

Source

pub fn fuel_emoji(&self) -> &'static str

Returns an emoji representation for the fuel type.

Provides visual indicators suitable for maps, mobile interfaces, and quick identification of fuel types in user interfaces. Returns generic fuel emoji if type is unknown.

Source

pub fn update_time_in_timezone(&self, tz: &TimeZone) -> Zoned

Gets the update time in a specific timezone.

Converts the update timestamp to a specified timezone for display in local time contexts or international applications.

Trait Implementations§

Source§

impl Clone for FuelPrice

Source§

fn clone(&self) -> FuelPrice

Returns a duplicate 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 FuelPrice

Source§

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

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

impl<'de> Deserialize<'de> for FuelPrice

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for FuelPrice

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 for FuelPrice

Source§

fn eq(&self, other: &FuelPrice) -> 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 Serialize for FuelPrice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for FuelPrice

Source§

impl StructuralPartialEq for FuelPrice

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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 = 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,