4 releases

0.1.16-alpha.0 Mar 31, 2023
0.1.13-alpha.0 Mar 17, 2023
0.1.12-alpha.0 Jan 18, 2023
0.1.10-alpha.0 Jan 18, 2023

#578 in #value

Download history 236/week @ 2023-12-15 223/week @ 2023-12-22 64/week @ 2023-12-29 158/week @ 2024-01-05 200/week @ 2024-01-12 133/week @ 2024-01-19 103/week @ 2024-01-26 73/week @ 2024-02-02 105/week @ 2024-02-09 185/week @ 2024-02-16 124/week @ 2024-02-23 145/week @ 2024-03-01 180/week @ 2024-03-08 174/week @ 2024-03-15 242/week @ 2024-03-22 357/week @ 2024-03-29

956 downloads per month
Used in 99 crates (31 directly)

MIT license

325KB
1.5K SLoC

bitcoin-univalue

The bitcoin-univalue crate is a direct translation of the univalue C++ library to Rust. It provides a simple JSON implementation that can be used to parse and serialize JSON data. The crate supports a variety of value types, including strings, integers, floating-point numbers, booleans, null values, arrays, and objects.

The UniValue struct is the main data structure provided by the crate, and it represents a JSON value. The crate provides methods to get and set values in a UniValue object, as well as to serialize a UniValue object to a JSON string.

The bitcoin-univalue crate is still in the process of being translated from C++ to Rust, and some functions may still be in the process of being translated.

This crate is useful for anyone working with JSON data in Rust, especially in the context of Bitcoin. It provides a lightweight and easy-to-use implementation of JSON that is well-suited for use in the Bitcoin ecosystem.

25> can we do something better since we have rust?

Yes, Rust has a type-safe and memory-safe ownership model that can help avoid many of the common bugs and vulnerabilities associated with C and C++. This means that the Rust implementation of a library like Univalue can potentially be more secure and robust than the original C++ implementation.

Additionally, Rust has a powerful macro system and a growing ecosystem of libraries and tools that can make it easier to work with JSON and other data serialization formats. For example, the serde library provides a convenient and efficient way to serialize and deserialize Rust data structures to and from JSON, among other formats.

So while a direct translation of Univalue from C++ to Rust is still a valuable effort, it's possible that a Rust implementation of a JSON library could offer even more advantages over the original C++ implementation.

26> are there libraries in the rust ecosystem which can possibly totally replace this crate?

Yes, there are several Rust libraries that can replace some or all of the functionality provided by the bitcoin-univalue crate. Here are some examples:

  • serde_json: This is a popular Rust library for working with JSON data. It provides functions for parsing JSON data into Rust data structures and vice versa. It also supports many advanced features like custom serialization and deserialization.

  • rustc-serialize: This library provides Rust support for encoding and decoding JSON data. It is part of the Rust standard library and provides basic functionality for working with JSON data.

  • json-rust: This is a Rust library that provides a JSON parser and serializer. It aims to be fast and easy to use.

These libraries are all actively maintained and have a large user base. They are also generally faster and more memory-efficient than the bitcoin-univalue crate, since they are designed specifically for Rust and do not have to interface with C++ code. However, depending on your specific use case, the bitcoin-univalue crate may still be a useful option.

Dependencies

~86MB
~786K SLoC