alexpikalov / cdrs-helpers-derive Goto Github PK
View Code? Open in Web Editor NEWProcedural macros that derive helper traits for CDRS Cassandra to Rust types conversion back and forth
Procedural macros that derive helper traits for CDRS Cassandra to Rust types conversion back and forth
This would allow people to extend your macros in theirs.
Trying to deserialize an enum contained in a udt results in a panic:
Invalid conversion. Cannot convert Tinyint into UDT (valid types: UDT).
This happens because https://github.com/AlexPikalov/cdrs-helpers-derive/blob/master/src/common.rs#L109 assumes everything unknown is a UDT.
When attempting to use the TryFromRow derive macro, the Rust compiler will complain about "expected trait, found derive macro "TryFromRow" not a trait [E0404].
Rust Version: 1.46.0
Crate Version: 0.3.3
cdrs Crate Version: 2.3.3
Example:
#[path = "./common.rs"]
mod common;
use cdrs_helpers_derive::*;
use common::UniqueId;
use juniper::GraphQLObject;
//#[derive(Clone, Debug, GraphQLObject, IntoCDRSValue, TryFromRow)]
#[derive(TryFromRow)]
#[graphql(description = "An account in the global system")]
pub struct Entity {
pub uid: String,
pub sid: String,
pub display_name: String,
}
impl UniqueId for Entity {
fn uid(&self) -> &str {
&self.uid
}
}
impl Entity {
fn sid(&self) -> &str {
&self.sid
}
fn display_name(&self) -> &str {
&self.display_name
}
}
pub struct NewEntity<'a> {
pub sid: &'a str,
pub display_name: &'a str,
}
pub struct NewEntityInput {
pub sid: String,
pub display_name: String,
}
The current dependencies are pretty outdated and some types that are used in this crate are not available anymore in newer versions of the dependencies. There are breaking changes, but the newer versions have features that can be useful.
Have a problem with nested UDT SELECT query (INSERT is fine, verified data with cqlsh shell).
I use scylla database.
From backtrace looks like this place panics
macro_rules! list_as_rust {
($($into_type:tt)+) => (
impl AsRustType<Vec<$($into_type)+>> for List {
fn as_rust_type(&self) -> Result<Option<Vec<$($into_type)+>>> {
match self.metadata.value {
Some(ColTypeOptionValue::CList(ref type_option)) |
Some(ColTypeOptionValue::CSet(ref type_option)) => {
let type_option_ref = type_option.as_ref();
let convert = self
.map(|bytes| {
as_rust_type!(type_option_ref, bytes, $($into_type)+)
.unwrap()
// item in a list supposed to be a non-null value.
// TODO: check if it's true
.unwrap()
});
Ok(Some(convert))
},
_ => Err(Error::General(format!("Invalid conversion. \
Cannot convert {:?} into List (valid types: List, Set).",
self.metadata.value)))
}
}
}
);
}
as_rust_type!(type_option_ref, bytes, $($into_type)+)
.unwrap()
// item in a list supposed to be a non-null value.
// TODO: check if it's true
.unwrap()
.unwrap in particular. Although I don't insert empty list (Vec) I assume it should initialize empty Vec on Rust side or did I misunderstood something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.