Sha256: e484e96f71c006b4440f05f936935bc8ea44c4db2bd28a5d23a62c5235fa56bc

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

use polars::prelude::*;

use crate::RbExpr;

impl RbExpr {
    pub fn bin_contains(&self, lit: Vec<u8>) -> Self {
        self.inner.clone().binary().contains_literal(lit).into()
    }

    pub fn bin_ends_with(&self, sub: Vec<u8>) -> Self {
        self.inner.clone().binary().ends_with(sub).into()
    }

    pub fn bin_starts_with(&self, sub: Vec<u8>) -> Self {
        self.inner.clone().binary().starts_with(sub).into()
    }

    pub fn bin_hex_decode(&self, strict: bool) -> Self {
        self.clone()
            .inner
            .map(
                move |s| {
                    s.binary()?
                        .hex_decode(strict)
                        .map(|s| Some(s.into_series()))
                },
                GetOutput::same_type(),
            )
            .with_fmt("bin.hex_decode")
            .into()
    }

    pub fn bin_base64_decode(&self, strict: bool) -> Self {
        self.clone()
            .inner
            .map(
                move |s| {
                    s.binary()?
                        .base64_decode(strict)
                        .map(|s| Some(s.into_series()))
                },
                GetOutput::same_type(),
            )
            .with_fmt("bin.base64_decode")
            .into()
    }

    pub fn bin_hex_encode(&self) -> Self {
        self.clone()
            .inner
            .map(
                move |s| s.binary().map(|s| Some(s.hex_encode().into_series())),
                GetOutput::same_type(),
            )
            .with_fmt("bin.hex_encode")
            .into()
    }

    pub fn bin_base64_encode(&self) -> Self {
        self.clone()
            .inner
            .map(
                move |s| s.binary().map(|s| Some(s.base64_encode().into_series())),
                GetOutput::same_type(),
            )
            .with_fmt("bin.base64_encode")
            .into()
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polars-df-0.6.0 ext/polars/src/expr/binary.rs
polars-df-0.5.0 ext/polars/src/expr/binary.rs