Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/function_expr/binary.rs
8420 views
1
#[cfg(feature = "serde")]
2
use serde::{Deserialize, Serialize};
3
4
use 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)]
9
pub 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
/// The parameters are destination type, and whether to use little endian
24
/// encoding.
25
Reinterpret(DataTypeExpr, bool),
26
Slice,
27
Head,
28
Tail,
29
Get(bool),
30
}
31
32
impl Display for BinaryFunction {
33
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
34
use BinaryFunction::*;
35
let s = match self {
36
Contains => "contains",
37
StartsWith => "starts_with",
38
EndsWith => "ends_with",
39
#[cfg(feature = "binary_encoding")]
40
HexDecode(_) => "hex_decode",
41
#[cfg(feature = "binary_encoding")]
42
HexEncode => "hex_encode",
43
#[cfg(feature = "binary_encoding")]
44
Base64Decode(_) => "base64_decode",
45
#[cfg(feature = "binary_encoding")]
46
Base64Encode => "base64_encode",
47
Size => "size_bytes",
48
#[cfg(feature = "binary_encoding")]
49
Reinterpret(_, _) => "reinterpret",
50
Slice => "slice",
51
Head => "head",
52
Tail => "tail",
53
Get(_) => "get",
54
};
55
write!(f, "bin.{s}")
56
}
57
}
58
59