File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,3 +29,5 @@ pub mod plain_date_time;
2929pub mod plain_month_day;
3030pub mod plain_time;
3131pub mod plain_year_month;
32+
33+ pub mod time_zone;
Original file line number Diff line number Diff line change 1+ #[ diplomat:: bridge]
2+ #[ diplomat:: abi_rename = "temporal_rs_{0}" ]
3+ #[ diplomat:: attr( auto, namespace = "temporal_rs" ) ]
4+ pub mod ffi {
5+ use crate :: error:: ffi:: TemporalError ;
6+ use std:: str;
7+
8+ #[ diplomat:: opaque]
9+ pub struct TimeZone ( pub temporal_rs:: TimeZone ) ;
10+
11+ impl TimeZone {
12+ pub fn try_from_identifier_str ( ident : & DiplomatStr ) -> Result < Box < Self > , TemporalError > {
13+ let Ok ( ident) = str:: from_utf8 ( ident) else {
14+ return Err ( temporal_rs:: TemporalError :: range ( ) . into ( ) ) ;
15+ } ;
16+ temporal_rs:: TimeZone :: try_from_identifier_str ( ident)
17+ . map ( |x| Box :: new ( TimeZone ( x) ) )
18+ . map_err ( Into :: into)
19+ }
20+ pub fn try_from_str ( ident : & DiplomatStr ) -> Result < Box < Self > , TemporalError > {
21+ let Ok ( ident) = str:: from_utf8 ( ident) else {
22+ return Err ( temporal_rs:: TemporalError :: range ( ) . into ( ) ) ;
23+ } ;
24+ temporal_rs:: TimeZone :: try_from_str ( ident)
25+ . map ( |x| Box :: new ( TimeZone ( x) ) )
26+ . map_err ( Into :: into)
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments