Implement clock.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has failed
rust-test Build rust-test has failed

This commit is contained in:
Tom Alexander 2023-12-30 18:12:09 -05:00
parent f50415cb32
commit c46a935cfc
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -4,15 +4,17 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::Clock; use crate::types::Clock;
use crate::types::ClockStatus;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct WasmClock { pub struct WasmClock {
#[serde(flatten)] #[serde(rename = "value")]
pub(crate) additional_properties: AdditionalProperties, pub(crate) timestamp: Box<WasmAstNode>,
pub(crate) duration: Option<String>,
pub(crate) status: String,
} }
to_wasm!( to_wasm!(
@ -21,12 +23,20 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::Clock(original) }, { WasmAstNode::Clock(original) },
{ "TODO".into() }, { "clock".into() },
{ {
Ok(( Ok((
Vec::new(), Vec::new(),
WasmClock { WasmClock {
additional_properties: AdditionalProperties::default(), timestamp: Box::new(Into::<WasmAstNode>::into(
original.timestamp.to_wasm(wasm_context.clone())?,
)),
duration: original.duration.map(|s| s.to_owned()),
status: match original.status {
ClockStatus::Running => "running",
ClockStatus::Closed => "closed",
}
.to_owned(),
}, },
)) ))
} }