use chrono::prelude::*;
use edn_derive::Serialize;
use transistor::client::Crux;
use transistor::edn_rs::EdnError;
use transistor::types::response::EntityTxResponse;
use transistor::types::Actions;
use transistor::types::CruxId;
async fn entity_tx_timed() -> EntityTxResponse {
let person1 = Person {
crux__db___id: CruxId::new("calor-jorge-3"),
first_name: "Calors Michael".to_string(),
last_name: "Jorge".to_string(),
};
let person2 = Person {
crux__db___id: CruxId::new("silva-manuel-1"),
first_name: "Silva Diego".to_string(),
last_name: "Manuel".to_string(),
};
let client = Crux::new("localhost", "3000").http_client();
let timed = "2014-11-28T21:00:09-09:00"
.parse::<DateTime<FixedOffset>>()
.unwrap();
let actions = Actions::new()
.append_put_timed(person1.clone(), timed.clone())
.append_put_timed(person2, timed.clone());
let _ = Crux::new("localhost", "3000")
.http_client()
.tx_log(actions)
.await
.unwrap();
let entity_tx_body = client
.entity_tx_timed(person1.crux__db___id, None, Some(timed))
.await
.unwrap();
return entity_tx_body;
}
#[tokio::main]
async fn main() {
let entity = entity_tx_timed().await;
println!("\n Edn Body = {:#?}", entity);
}
#[tokio::test]
async fn test_entity_tx_timed() {
let entity = entity_tx_timed().await;
assert!(entity.tx___tx_id > 0);
}
#[derive(Debug, Clone, Serialize)]
#[allow(non_snake_case)]
pub struct Person {
crux__db___id: CruxId,
first_name: String,
last_name: String,
}