pub trait Serializeable: Sized {
// Required methods
fn to_bytes(&self) -> Result<Bytes>;
fn from_bytes_with_ctx(bytes: &[u8], ctx: &TaskContext) -> Result<Self>;
// Provided method
fn from_bytes(bytes: &[u8]) -> Result<Self> { ... }
}Expand description
Encodes something (such as Expr) to/from a stream of
bytes.
use datafusion_expr::{col, lit, Expr};
use datafusion_proto::bytes::Serializeable;
// Create a new `Expr` a < 32
let expr = col("a").lt(lit(5i32));
// Convert it to an opaque form
let bytes = expr.to_bytes().unwrap();
// Decode bytes from somewhere (over network, etc.)
let decoded_expr = Expr::from_bytes(&bytes).unwrap();
assert_eq!(expr, decoded_expr);Required Methods§
Sourcefn from_bytes_with_ctx(bytes: &[u8], ctx: &TaskContext) -> Result<Self>
fn from_bytes_with_ctx(bytes: &[u8], ctx: &TaskContext) -> Result<Self>
Convert bytes (the output of to_bytes) back into an object,
resolving user defined functions with the specified ctx
Provided Methods§
Sourcefn from_bytes(bytes: &[u8]) -> Result<Self>
fn from_bytes(bytes: &[u8]) -> Result<Self>
Convert bytes (the output of to_bytes) back into an object. This
will error if the serialized bytes contain any user defined functions,
in which case use from_bytes_with_ctx
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".