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§

source

fn to_bytes(&self) -> Result<Bytes>

Convert self to an opaque byte stream

source

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§

source

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

Implementations on Foreign Types§

source§

impl Serializeable for Expr

source§

fn to_bytes(&self) -> Result<Bytes>

source§

fn from_bytes_with_registry( bytes: &[u8], registry: &dyn FunctionRegistry ) -> Result<Self>

Implementors§