polars_plan/dsl/function_expr/
binary.rs

1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3
4use super::*;
5
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
8#[derive(Clone, PartialEq, Debug, Hash)]
9pub enum BinaryFunction {
10    Contains,
11    StartsWith,
12    EndsWith,
13    #[cfg(feature = "binary_encoding")]
14    HexDecode(bool),
15    #[cfg(feature = "binary_encoding")]
16    HexEncode,
17    #[cfg(feature = "binary_encoding")]
18    Base64Decode(bool),
19    #[cfg(feature = "binary_encoding")]
20    Base64Encode,
21    Size,
22    #[cfg(feature = "binary_encoding")]
23    FromBuffer(DataTypeExpr, bool),
24}
25
26impl Display for BinaryFunction {
27    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
28        use BinaryFunction::*;
29        let s = match self {
30            Contains => "contains",
31            StartsWith => "starts_with",
32            EndsWith => "ends_with",
33            #[cfg(feature = "binary_encoding")]
34            HexDecode(_) => "hex_decode",
35            #[cfg(feature = "binary_encoding")]
36            HexEncode => "hex_encode",
37            #[cfg(feature = "binary_encoding")]
38            Base64Decode(_) => "base64_decode",
39            #[cfg(feature = "binary_encoding")]
40            Base64Encode => "base64_encode",
41            Size => "size_bytes",
42            #[cfg(feature = "binary_encoding")]
43            FromBuffer(_, _) => "from_buffer",
44        };
45        write!(f, "bin.{s}")
46    }
47}