Comments (2)
There should be TryFrom
conversions for Value
into all equivalent native types - here's some pseudocode for example:
let some_hashmap: HashMap<String, i64> = HashMap::from_iter( ... );
let bolt_value = Value::from(some_hashmap); // This is a Value::Map
let native_value: HashMap<String, Value> = HashMap::try_from(bolt_value).unwrap();
// Or if your hashmap value type implements TryFrom<Value>...
let native_value: HashMap<String, i64> = HashMap::try_from(bolt_value).unwrap();
Something like that anyway... see here for more conversions. I noticed that some of them aren't showing up on docs.rs, which is a bit strange. Run cargo doc --open
on bolt-proto
and you should be able to see all of them.
Looking back at this, the Value
API could use some simplification - it would be nice to be able to just match
on a Value
to get the native type:
match value {
Value::Boolean(b) => ... // where b: bool
Value::String(s) => ... // where s: String
_ => ...
}
I will consider doing this at some point so there is no need for the TryFrom
conversions - that was sort of an experiment that didn't work out very well.
I'll also see about implementing serde's Serialize
trait so people don't need to write custom serializers.
from bolt-rs.
@lucis-fluxum thanks so much for the quick response. This is very helpful indeed.
I have actually found the TryFrom implementation by digging into the code and managed to write a simple serde-json serializer. But I totally agree with you; having that as part of the core crate would be super awesome.
from bolt-rs.
Related Issues (18)
- Missing Version Bump? HOT 2
- could not find `CommunicationError` in `error` HOT 1
- Example uses unavailable function compat HOT 4
- Appear Error "IO driver has terminated", How to solve HOT 1
- Serde Serialization/Deserialization HOT 2
- usage example HOT 4
- Question: How Connect to a Neo4j Cluster? HOT 2
- Hi! HOT 1
- Neo4j 4 support HOT 3
- Debug for Manager HOT 1
- QUESTION: how to connect to a different database HOT 1
- Production-readiness and contributions HOT 4
- GrapheneDB doesn't negotiate protocol version correctly HOT 2
- Question: Bolt v4 doc? HOT 2
- bolt-client v0.8.0 fails to build. bolt-proto v0.9.2 has incompatible with v0.9.1 change. HOT 2
- Iteration over a result set in bolt_client HOT 5
- Connect to a Neo4j Cluster HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolt-rs.