alamb commented on a change in pull request #9212:
URL: https://github.com/apache/arrow/pull/9212#discussion_r559493254
##########
File path: rust/arrow/src/datatypes.rs
##########
@@ -199,11 +199,18 @@ pub struct Field {
metadata: Option<BTreeMap<String, String>>,
}
-pub trait ArrowNativeType:
- fmt::Debug + Send + Sync + Copy + PartialOrd + FromStr + Default + 'static
-{
+/// Trait declaring any type that is serializable to JSON. This includes all
primitive types (bool, i32, etc.).
+pub trait JsonSerializable: 'static {
fn into_json_value(self) -> Option<Value>;
+}
+/// Trait expressing a Rust type that has the same in-memory representation
+/// as Arrow. This includes `i16`, `f32`, but excludes `bool` (which in arrow
is represented in bits).
+/// In little endian machines, types that implement [`ArrowNativeType`] can be
memcopied to arrow buffers
+/// as is.
+pub trait ArrowNativeType:
+ fmt::Debug + Send + Sync + Copy + PartialOrd + FromStr + Default +
JsonSerializable
Review comment:
This is a nice approach (breaking out the `JsonSerializable` part) 👍
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]