Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions temporal_capi/bindings/c/TimeZone.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions temporal_capi/bindings/cpp/temporal_rs/TimeZone.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 25 additions & 8 deletions temporal_capi/bindings/cpp/temporal_rs/TimeZone.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions temporal_capi/src/time_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
pub mod ffi {
use crate::error::ffi::TemporalError;
use alloc::boxed::Box;
use core::fmt::Write;
use core::str;
use diplomat_runtime::DiplomatWrite;

#[diplomat::opaque]
#[diplomat::transparent_convert]
Expand All @@ -19,11 +21,6 @@ pub mod ffi {
.map(|x| Box::new(TimeZone(x)))
.map_err(Into::into)
}
pub fn try_from_offset_str(ident: &DiplomatStr) -> Result<Box<Self>, TemporalError> {
temporal_rs::UtcOffset::from_utf8(ident)
.map(|x| Box::new(TimeZone(temporal_rs::TimeZone::UtcOffset(x))))
.map_err(Into::into)
}
pub fn try_from_str(ident: &DiplomatStr) -> Result<Box<Self>, TemporalError> {
let Ok(ident) = str::from_utf8(ident) else {
return Err(temporal_rs::TemporalError::range().into());
Expand All @@ -33,6 +30,22 @@ pub mod ffi {
.map_err(Into::into)
}

pub fn identifier(&self, write: &mut DiplomatWrite) -> Result<(), TemporalError> {
// TODO ideally this would use Writeable instead of allocating
let s = self.0.identifier()?;

// This can only fail in cases where the DiplomatWriteable is capped, we
// don't care about that.
let _ = write.write_str(&s);

Ok(())
}

#[allow(clippy::should_implement_trait)]
pub fn clone(&self) -> Box<TimeZone> {
Box::new(TimeZone(self.0.clone()))
}

#[cfg(feature = "compiled_data")]
pub fn is_valid(&self) -> bool {
self.0.is_valid()
Expand Down