pub struct ExpiryDate {
pub year: u8,
pub month: u8,
pub day: u8,
}Expand description
Represents a futures contract expiry date in YYMMDD format
§Example
use ccxt_core::types::symbol::ExpiryDate;
let expiry = ExpiryDate::new(24, 12, 31).unwrap();
assert_eq!(expiry.to_string(), "241231");Fields§
§year: u82-digit year (e.g., 24 for 2024)
month: u8Month (1-12)
day: u8Day (1-31)
Implementations§
Source§impl ExpiryDate
impl ExpiryDate
Sourcepub fn new(year: u8, month: u8, day: u8) -> Result<ExpiryDate, SymbolError>
pub fn new(year: u8, month: u8, day: u8) -> Result<ExpiryDate, SymbolError>
Create a new expiry date with validation
§Arguments
year- 2-digit year (0-99)month- Month (1-12)day- Day (1-31)
§Returns
Returns Ok(ExpiryDate) if the date is valid, or Err(SymbolError) if invalid.
§Example
use ccxt_core::types::symbol::ExpiryDate;
let valid = ExpiryDate::new(24, 12, 31);
assert!(valid.is_ok());
let invalid_month = ExpiryDate::new(24, 13, 1);
assert!(invalid_month.is_err());Trait Implementations§
Source§impl Clone for ExpiryDate
impl Clone for ExpiryDate
Source§fn clone(&self) -> ExpiryDate
fn clone(&self) -> ExpiryDate
Returns a duplicate 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 ExpiryDate
impl Debug for ExpiryDate
Source§impl Default for ExpiryDate
impl Default for ExpiryDate
Source§fn default() -> ExpiryDate
fn default() -> ExpiryDate
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ExpiryDate
impl<'de> Deserialize<'de> for ExpiryDate
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExpiryDate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExpiryDate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ExpiryDate
impl Display for ExpiryDate
Source§impl FromStr for ExpiryDate
impl FromStr for ExpiryDate
Source§fn from_str(s: &str) -> Result<ExpiryDate, <ExpiryDate as FromStr>::Err>
fn from_str(s: &str) -> Result<ExpiryDate, <ExpiryDate as FromStr>::Err>
Parse an expiry date from YYMMDD format
§Example
use ccxt_core::types::symbol::ExpiryDate;
use std::str::FromStr;
let expiry = ExpiryDate::from_str("241231").unwrap();
assert_eq!(expiry.year, 24);
assert_eq!(expiry.month, 12);
assert_eq!(expiry.day, 31);Source§type Err = SymbolError
type Err = SymbolError
The associated error which can be returned from parsing.
Source§impl Hash for ExpiryDate
impl Hash for ExpiryDate
Source§impl PartialEq for ExpiryDate
impl PartialEq for ExpiryDate
Source§impl Serialize for ExpiryDate
impl Serialize for ExpiryDate
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for ExpiryDate
impl Eq for ExpiryDate
Auto Trait Implementations§
impl Freeze for ExpiryDate
impl RefUnwindSafe for ExpiryDate
impl Send for ExpiryDate
impl Sync for ExpiryDate
impl Unpin for ExpiryDate
impl UnwindSafe for ExpiryDate
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.