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: MoneyThe 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: TimestampThe 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
impl FuelPrice
Sourcepub fn fuel_type(&self) -> Option<FuelType>
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.
Sourcepub fn update_time(&self) -> Timestamp
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
impl FuelPrice
Sourcepub const fn new(
fuel_type: Option<FuelType>,
price: Money,
update_time: Timestamp,
) -> Self
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.
Sourcepub fn with_current_time(fuel_type: Option<FuelType>, price: Money) -> Self
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.
Sourcepub fn age(&self) -> Result<Span, Error>
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.
Sourcepub fn is_very_recent(&self) -> Result<bool, Error>
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.
Sourcepub fn is_fresh(&self) -> Result<bool, Error>
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.
Sourcepub fn is_stale(&self) -> Result<bool, Error>
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.
Sourcepub fn update_time_description(&self) -> Result<String, Error>
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.
Sourcepub fn freshness_indicator(&self) -> Result<FreshnessIndicator, Error>
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.
Sourcepub fn formatted_price(&self) -> String
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.
Sourcepub fn compact_price(&self) -> String
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.
Sourcepub fn is_competitive(&self, average_price: Option<&Money>) -> bool
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.
Sourcepub fn fuel_type_name(&self) -> String
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.
Sourcepub fn full_description(&self) -> String
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.
Sourcepub fn has_valid_price(&self) -> bool
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.
Sourcepub fn compare_price(&self, other: &Self) -> Option<Ordering>
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.
Sourcepub fn fuel_emoji(&self) -> &'static str
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.
Sourcepub fn update_time_in_timezone(&self, tz: &TimeZone) -> Zoned
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<'de> Deserialize<'de> for FuelPrice
impl<'de> Deserialize<'de> for FuelPrice
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for FuelPrice
impl StructuralPartialEq for FuelPrice
Auto Trait Implementations§
impl Freeze for FuelPrice
impl RefUnwindSafe for FuelPrice
impl Send for FuelPrice
impl Sync for FuelPrice
impl Unpin for FuelPrice
impl UnsafeUnpin for FuelPrice
impl UnwindSafe for FuelPrice
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.