Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
serde_traitobject
Serializable trait objects.
This library enables the serialization of trait objects such that they can be sent between other processes running the same binary.
For example, if you have multiple forks of a process, or the same binary running on each of a cluster of machines, this library would help you to send trait objects between them.
The heart of this crate is the Serialize and Deserialize traits. They are automatically implemented for all T: serde::Serialize
and all T: serde::de::DeserializeOwned
respectively.
Any trait can be made (de)serializable when made into a trait object by simply adding them as supertraits:
extern crate serde_derive;
extern crate serde_traitobject;
] );
// Woohoo, `Message` is now serializable!
There are two ways to use serde_traitobject to handle the (de)serialization:
#[serde(with = "serde_traitobject")]
field attribute on a boxed trait object, which instructs serde to use the serialize and deserialize functions;- The Box, Rc and Arc structs, which are simple wrappers around their stdlib counterparts that automatically handle (de)serialization without needing the above annotation;
Additionally, there are several convenience traits implemented that extend their stdlib counterparts:
These are automatically implemented on all (de)serializable implementors of their stdlib counterparts:
extern crate serde_derive;
extern crate serde_json;
extern crate serde_traitobject as s;
use Any;
let my_struct = MyStruct ;
let erased: Box = new;
let serialized = to_string.unwrap;
let deserialized: Box = from_str.unwrap;
let downcast: = Box:: downcast.unwrap;
println!;
// MyStruct { foo: "abc", bar: 123 }
Note
This crate works by wrapping the vtable pointer with relative::Pointer such that it can safely be sent between processes.
This currently requires Rust nightly.
License
Licensed under Apache License, Version 2.0, (LICENSE.txt or http://www.apache.org/licenses/LICENSE-2.0).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.