polars_plan/dsl/
binary.rs1use super::*;
2pub struct BinaryNameSpace(pub(crate) Expr);
4
5impl BinaryNameSpace {
6 pub fn contains_literal(self, pat: Expr) -> Expr {
8 self.0.map_many_private(
9 FunctionExpr::BinaryExpr(BinaryFunction::Contains),
10 &[pat],
11 false,
12 Some(Default::default()),
13 )
14 }
15
16 pub fn ends_with(self, sub: Expr) -> Expr {
18 self.0.map_many_private(
19 FunctionExpr::BinaryExpr(BinaryFunction::EndsWith),
20 &[sub],
21 false,
22 Some(Default::default()),
23 )
24 }
25
26 pub fn starts_with(self, sub: Expr) -> Expr {
28 self.0.map_many_private(
29 FunctionExpr::BinaryExpr(BinaryFunction::StartsWith),
30 &[sub],
31 false,
32 Some(Default::default()),
33 )
34 }
35
36 pub fn size_bytes(self) -> Expr {
38 self.0
39 .map_private(FunctionExpr::BinaryExpr(BinaryFunction::Size))
40 }
41
42 #[cfg(feature = "binary_encoding")]
43 pub fn hex_decode(self, strict: bool) -> Expr {
44 self.0
45 .map_private(FunctionExpr::BinaryExpr(BinaryFunction::HexDecode(strict)))
46 }
47
48 #[cfg(feature = "binary_encoding")]
49 pub fn hex_encode(self) -> Expr {
50 self.0
51 .map_private(FunctionExpr::BinaryExpr(BinaryFunction::HexEncode))
52 }
53
54 #[cfg(feature = "binary_encoding")]
55 pub fn base64_decode(self, strict: bool) -> Expr {
56 self.0
57 .map_private(FunctionExpr::BinaryExpr(BinaryFunction::Base64Decode(
58 strict,
59 )))
60 }
61
62 #[cfg(feature = "binary_encoding")]
63 pub fn base64_encode(self) -> Expr {
64 self.0
65 .map_private(FunctionExpr::BinaryExpr(BinaryFunction::Base64Encode))
66 }
67
68 #[cfg(feature = "binary_encoding")]
69 pub fn from_buffer(self, to_type: DataType, is_little_endian: bool) -> Expr {
70 self.0
71 .map_private(FunctionExpr::BinaryExpr(BinaryFunction::FromBuffer(
72 to_type,
73 is_little_endian,
74 )))
75 }
76}