pub trait Serializeable: Sized {
// Required methods
fn to_bytes(&self) -> Result<Bytes>;
fn from_bytes_with_registry(
bytes: &[u8],
registry: &dyn FunctionRegistry,
) -> 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_registry(
bytes: &[u8],
registry: &dyn FunctionRegistry,
) -> Result<Self>
fn from_bytes_with_registry( bytes: &[u8], registry: &dyn FunctionRegistry, ) -> Result<Self>
Convert bytes (the output of to_bytes) back into an
object resolving user defined functions with the specified
registry
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_registry
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.