Skip to content

Commit

Permalink
Fix/timestamp codegen (#81)
Browse files Browse the repository at this point in the history
* don't overwrite RUST_LOG for providers if it's more detailed than a simple level value

Signed-off-by: stevelr <[email protected]>

* add Timestamp::new() constructor and Timestamp Into<SystemTime>

Signed-off-by: stevelr <[email protected]>

* implement Timestamp encode/decode

Signed-off-by: stevelr <[email protected]>

* add PartialEq to RpcError

Signed-off-by: stevelr <[email protected]>

* bump crate to 0.3.3

Signed-off-by: stevelr <[email protected]>
  • Loading branch information
stevelr authored Feb 14, 2022
1 parent 0e3a52b commit e47b2b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "weld-codegen"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
authors = [ "wasmcloud Team" ]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/decode_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn decode_double() -> &'static str {
"d.f64()?"
}
fn decode_timestamp() -> &'static str {
todo!(); // tag timestamp
"wasmbus_rpc::Timestamp{ sec: d.i64()?, nsec: d.u32()? }"
}
fn decode_big_integer() -> &'static str {
todo!(); // tag big int
Expand Down
8 changes: 6 additions & 2 deletions codegen/src/encode_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ fn encode_double(val: ValExpr) -> String {
fn encode_document(val: ValExpr) -> String {
format!("e.bytes({})?;\n", val.as_ref())
}
fn encode_timestamp(_val: ValExpr) -> String {
todo!(); // tag timestamp
fn encode_timestamp(val: ValExpr) -> String {
format!(
"e.i64({}.sec)?;\ne.u32({}.nsec)?;\n",
val.as_str(),
val.as_str()
)
}
fn encode_big_integer(_val: ValExpr) -> String {
todo!(); // tag big int
Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};

/// An error that can occur in the processing of an RPC. This is not request-specific errors but
/// rather cross-cutting errors that can always occur.
#[derive(thiserror::Error, Debug, Serialize, Deserialize)]
#[derive(thiserror::Error, Debug, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum RpcError {
/// The request exceeded its deadline.
Expand Down

0 comments on commit e47b2b0

Please sign in to comment.