diff --git a/Cargo.lock b/Cargo.lock index 34d712e..7830155 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -941,6 +941,12 @@ dependencies = [ "regex", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1324,6 +1330,7 @@ dependencies = [ "chrono", "chrono-tz", "flutter_rust_bridge", + "paste", "polars", ] diff --git a/packages/polars/lib/src/expr.dart b/packages/polars/lib/src/expr.dart index 4de093e..43787ac 100644 --- a/packages/polars/lib/src/expr.dart +++ b/packages/polars/lib/src/expr.dart @@ -1,3 +1,5 @@ +import 'package:polars/src/str.dart'; + import 'wrapper/entry.dart'; import 'wrapper/expr.dart'; @@ -73,7 +75,15 @@ extension ExprExt on Expr { Expr alias(String name) => Expr.alias(this, name); Expr get aggGroups => Expr.agg(AggExpr.aggGroups(this)); - Expr cast(DataType dataType, {bool strict = false}) => + + /// Attempt to [cast](https://docs.pola.rs/user-guide/expressions/casting) a column's [DataType] to a new one. + /// + /// By default, strict mode is enabled and restricts certain types of casts: + /// - String-to-numeric casts will throw if the string cannot be parsed as a number. + /// - Downcasts (e.g. [int64] to [int32]) that result in overflowing values will throw. + /// + /// When strict mode is disabled, these casts will return null instead. + Expr cast(DataType dataType, {bool strict = true}) => Expr.cast(expr: this, dataType: dataType, strict: strict); Expr equalMissing(Object? other) => Expr.binaryExpr(left: this, op: Operator.eqValidity, right: other.expr); @@ -98,8 +108,10 @@ extension ExprExt on Expr { Expr.slice(input: this, offset: offset.expr, length: length.expr); /// Calculate the standard deviation of this expression with the specified - /// [dof] or [delta degrees of freedom](https://en.wikipedia.org/wiki/Degrees_of_freedom_(statistics)). + /// [ddof] or [delta degrees of freedom](https://en.wikipedia.org/wiki/Degrees_of_freedom_(statistics)). Expr std(int ddof) => Expr.agg(AggExpr.std(this, ddof)); + + StrNamespace get str => StrNamespace(this); } Expr col(String column) => Expr.column(column); @@ -108,13 +120,48 @@ Expr cols(Iterable columns) => Expr dtypes(Iterable dtypes) => Expr.dtypeColumn(dtypes.toList(growable: false)); -Expr when( - Expr condition, { +/// Begin a chain of [when-then-otherwise](https://docs.pola.rs/user-guide/expressions/functions/#conditionals) expressions. +/// +/// ### Example: +/// ```dart +/// final data = await df.clone().lazy().select([ +/// when(col('a') > 0, then: col('a') * 2) +/// .when(col('a') < 0, then: col('a') * 3) +/// .otherwise(col('a')) +/// .alias('new_a'), +/// ]).collect(); +/// ``` +When when( + Object? condition, { required Object? then, - Object? otherwise = const Expr.literal(LiteralValue.Null()), }) => - Expr.ternary( - predicate: condition, truthy: then.expr, falsy: otherwise.expr); + When(condition, then); + +class When { + final List<(Expr, Expr)> _chains; + Expr _otherwise = const Expr.literal(LiteralValue.Null()); + + When(Object? condition, Object? then) + : _chains = [(condition.expr, then.expr)]; + + When when(Object? condition, {required Object? then}) { + _chains.add((condition.expr, then.expr)); + return this; + } + + Expr otherwise(Object? otherwise) { + _otherwise = otherwise.expr; + return expr; + } + + Expr get expr { + var root = _otherwise; + for (final (cond, truthy) in _chains.reversed) { + root = Expr.ternary(predicate: cond, truthy: truthy, falsy: root); + } + return root; + } +} /// Extensions on [String]. extension StringPolars on String { @@ -199,6 +246,8 @@ extension DynamicPolars on dynamic { DateTime value => value.expr, Duration value => value.expr, Expr expr => expr, + When ternary => ternary.expr, + StrNamespace ns => ns.expr, LiteralValue lit => Expr.literal(lit), null => const Expr.literal(LiteralValue.Null()), _ => '$this'.expr, diff --git a/packages/polars/lib/src/frb_generated.dart b/packages/polars/lib/src/frb_generated.dart index 02772c3..0ad1f62 100644 --- a/packages/polars/lib/src/frb_generated.dart +++ b/packages/polars/lib/src/frb_generated.dart @@ -11,6 +11,7 @@ import 'wrapper/df.dart'; import 'wrapper/entry.dart'; import 'wrapper/expr.dart'; import 'wrapper/series.dart'; +import 'wrapper/str.dart'; /// Main entrypoint of the Rust API class RustLib extends BaseEntrypoint { @@ -825,6 +826,146 @@ abstract class RustLibApi extends BaseApi { Series seriesVarAsSeries( {required Series that, required int ddof, dynamic hint}); + Expr exprStrConcat( + {required Expr that, + required String delimiter, + bool ignoreNulls = true, + dynamic hint}); + + Expr exprStrContains( + {required Expr that, + required Expr pat, + bool strict = true, + dynamic hint}); + + Expr exprStrContainsLiteral( + {required Expr that, required Expr pat, dynamic hint}); + + Expr exprStrCountMatches( + {required Expr that, + required Expr pat, + bool literal = false, + dynamic hint}); + + Expr exprStrEndsWith({required Expr that, required Expr pat, dynamic hint}); + + Expr exprStrExplode({required Expr that, dynamic hint}); + + Expr exprStrExtract( + {required Expr that, + required String pat, + required int groupIndex, + dynamic hint}); + + Expr exprStrExtractAll({required Expr that, required Expr pat, dynamic hint}); + + Expr exprStrLenBytes({required Expr that, dynamic hint}); + + Expr exprStrLenChars({required Expr that, dynamic hint}); + + Expr exprStrReplace( + {required Expr that, + required Expr pat, + required Expr val, + bool literal = false, + dynamic hint}); + + Expr exprStrReplaceAll( + {required Expr that, + required Expr pat, + required Expr val, + bool literal = false, + dynamic hint}); + + Expr exprStrReplaceN( + {required Expr that, + required Expr pat, + required Expr val, + bool literal = false, + required int n, + dynamic hint}); + + Expr exprStrSlice( + {required Expr that, required int start, int? length, dynamic hint}); + + Expr exprStrSplit( + {required Expr that, + required Expr by, + bool inclusive = false, + dynamic hint}); + + Expr exprStrSplitExact( + {required Expr that, + required Expr by, + required int n, + bool inclusive = false, + dynamic hint}); + + Expr exprStrSplitn( + {required Expr that, required Expr by, required int n, dynamic hint}); + + Expr exprStrStripChars( + {required Expr that, required Expr matches, dynamic hint}); + + Expr exprStrStripCharsEnd( + {required Expr that, required Expr matches, dynamic hint}); + + Expr exprStrStripCharsStart( + {required Expr that, required Expr matches, dynamic hint}); + + Expr exprStrStripPrefix( + {required Expr that, required Expr prefix, dynamic hint}); + + Expr exprStrStripSuffix( + {required Expr that, required Expr suffix, dynamic hint}); + + Expr exprStrToDate( + {required Expr that, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + dynamic hint}); + + Expr exprStrToDatetime( + {required Expr that, + TimeUnit? timeUnit, + String? timeZone, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + dynamic hint}); + + Expr exprStrToInteger( + {required Expr that, + required int base, + bool strict = true, + dynamic hint}); + + Expr exprStrToLowercase({required Expr that, dynamic hint}); + + Expr exprStrToTime( + {required Expr that, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + dynamic hint}); + + Expr exprStrToUppercase({required Expr that, dynamic hint}); + + Expr exprStrptime( + {required Expr that, + required DataType dtype, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + dynamic hint}); + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_PExpr; RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_PExpr; @@ -7005,75 +7146,911 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["that", "ddof"], ); - RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_PExpr => - wire.rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafePExpr; - - RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_PExpr => - wire.rust_arc_decrement_strong_count_RustOpaque_AssertUnwindSafePExpr; + @override + Expr exprStrConcat( + {required Expr that, + required String delimiter, + bool ignoreNulls = true, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_String(delimiter); + var arg2 = cst_encode_bool(ignoreNulls); + return wire.wire_Expr_str_concat(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrConcatConstMeta, + argValues: [that, delimiter, ignoreNulls], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_SpecialEqPSeries => wire - .rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafeSpecialEqPSeries; + TaskConstMeta get kExprStrConcatConstMeta => const TaskConstMeta( + debugName: "Expr_str_concat", + argNames: ["that", "delimiter", "ignoreNulls"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_SpecialEqPSeries => wire - .rust_arc_decrement_strong_count_RustOpaque_AssertUnwindSafeSpecialEqPSeries; + @override + Expr exprStrContains( + {required Expr that, + required Expr pat, + bool strict = true, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + var arg2 = cst_encode_bool(strict); + return wire.wire_Expr_str_contains(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrContainsConstMeta, + argValues: [that, pat, strict], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_DataFrame => wire - .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockDataFrame; + TaskConstMeta get kExprStrContainsConstMeta => const TaskConstMeta( + debugName: "Expr_str_contains", + argNames: ["that", "pat", "strict"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_DataFrame => wire - .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockDataFrame; + @override + Expr exprStrContainsLiteral( + {required Expr that, required Expr pat, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + return wire.wire_Expr_str_contains_literal(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrContainsLiteralConstMeta, + argValues: [that, pat], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_LazyFrame => wire - .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockLazyFrame; + TaskConstMeta get kExprStrContainsLiteralConstMeta => const TaskConstMeta( + debugName: "Expr_str_contains_literal", + argNames: ["that", "pat"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_LazyFrame => wire - .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockLazyFrame; + @override + Expr exprStrCountMatches( + {required Expr that, + required Expr pat, + bool literal = false, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + var arg2 = cst_encode_bool(literal); + return wire.wire_Expr_str_count_matches(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrCountMatchesConstMeta, + argValues: [that, pat, literal], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_LazyGroupBy => wire - .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockLazyGroupBy; + TaskConstMeta get kExprStrCountMatchesConstMeta => const TaskConstMeta( + debugName: "Expr_str_count_matches", + argNames: ["that", "pat", "literal"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_LazyGroupBy => wire - .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockLazyGroupBy; + @override + Expr exprStrEndsWith({required Expr that, required Expr pat, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + return wire.wire_Expr_str_ends_with(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrEndsWithConstMeta, + argValues: [that, pat], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_OptionSchema => wire - .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockOptionSchema; + TaskConstMeta get kExprStrEndsWithConstMeta => const TaskConstMeta( + debugName: "Expr_str_ends_with", + argNames: ["that", "pat"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_OptionSchema => wire - .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockOptionSchema; + @override + Expr exprStrExplode({required Expr that, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + return wire.wire_Expr_str_explode(arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrExplodeConstMeta, + argValues: [that], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_OptionVecSeries => wire - .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockOptionVecSeries; + TaskConstMeta get kExprStrExplodeConstMeta => const TaskConstMeta( + debugName: "Expr_str_explode", + argNames: ["that"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_OptionVecSeries => wire - .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockOptionVecSeries; + @override + Expr exprStrExtract( + {required Expr that, + required String pat, + required int groupIndex, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_String(pat); + var arg2 = cst_encode_usize(groupIndex); + return wire.wire_Expr_str_extract(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrExtractConstMeta, + argValues: [that, pat, groupIndex], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_Schema => - wire.rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockSchema; + TaskConstMeta get kExprStrExtractConstMeta => const TaskConstMeta( + debugName: "Expr_str_extract", + argNames: ["that", "pat", "groupIndex"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_Schema => - wire.rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockSchema; + @override + Expr exprStrExtractAll( + {required Expr that, required Expr pat, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + return wire.wire_Expr_str_extract_all(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrExtractAllConstMeta, + argValues: [that, pat], + apiImpl: this, + hint: hint, + )); + } - RustArcIncrementStrongCountFnType - get rust_arc_increment_strong_count_Series => - wire.rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockSeries; + TaskConstMeta get kExprStrExtractAllConstMeta => const TaskConstMeta( + debugName: "Expr_str_extract_all", + argNames: ["that", "pat"], + ); - RustArcDecrementStrongCountFnType - get rust_arc_decrement_strong_count_Series => - wire.rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockSeries; + @override + Expr exprStrLenBytes({required Expr that, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + return wire.wire_Expr_str_len_bytes(arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrLenBytesConstMeta, + argValues: [that], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrLenBytesConstMeta => const TaskConstMeta( + debugName: "Expr_str_len_bytes", + argNames: ["that"], + ); + + @override + Expr exprStrLenChars({required Expr that, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + return wire.wire_Expr_str_len_chars(arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrLenCharsConstMeta, + argValues: [that], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrLenCharsConstMeta => const TaskConstMeta( + debugName: "Expr_str_len_chars", + argNames: ["that"], + ); + + @override + Expr exprStrReplace( + {required Expr that, + required Expr pat, + required Expr val, + bool literal = false, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + var arg2 = cst_encode_box_autoadd_expr(val); + var arg3 = cst_encode_bool(literal); + return wire.wire_Expr_str_replace(arg0, arg1, arg2, arg3); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrReplaceConstMeta, + argValues: [that, pat, val, literal], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrReplaceConstMeta => const TaskConstMeta( + debugName: "Expr_str_replace", + argNames: ["that", "pat", "val", "literal"], + ); + + @override + Expr exprStrReplaceAll( + {required Expr that, + required Expr pat, + required Expr val, + bool literal = false, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + var arg2 = cst_encode_box_autoadd_expr(val); + var arg3 = cst_encode_bool(literal); + return wire.wire_Expr_str_replace_all(arg0, arg1, arg2, arg3); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrReplaceAllConstMeta, + argValues: [that, pat, val, literal], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrReplaceAllConstMeta => const TaskConstMeta( + debugName: "Expr_str_replace_all", + argNames: ["that", "pat", "val", "literal"], + ); + + @override + Expr exprStrReplaceN( + {required Expr that, + required Expr pat, + required Expr val, + bool literal = false, + required int n, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(pat); + var arg2 = cst_encode_box_autoadd_expr(val); + var arg3 = cst_encode_bool(literal); + var arg4 = cst_encode_i_64(n); + return wire.wire_Expr_str_replace_n(arg0, arg1, arg2, arg3, arg4); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrReplaceNConstMeta, + argValues: [that, pat, val, literal, n], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrReplaceNConstMeta => const TaskConstMeta( + debugName: "Expr_str_replace_n", + argNames: ["that", "pat", "val", "literal", "n"], + ); + + @override + Expr exprStrSlice( + {required Expr that, required int start, int? length, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_i_64(start); + var arg2 = cst_encode_opt_box_autoadd_u_64(length); + return wire.wire_Expr_str_slice(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrSliceConstMeta, + argValues: [that, start, length], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrSliceConstMeta => const TaskConstMeta( + debugName: "Expr_str_slice", + argNames: ["that", "start", "length"], + ); + + @override + Expr exprStrSplit( + {required Expr that, + required Expr by, + bool inclusive = false, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(by); + var arg2 = cst_encode_bool(inclusive); + return wire.wire_Expr_str_split(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrSplitConstMeta, + argValues: [that, by, inclusive], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrSplitConstMeta => const TaskConstMeta( + debugName: "Expr_str_split", + argNames: ["that", "by", "inclusive"], + ); + + @override + Expr exprStrSplitExact( + {required Expr that, + required Expr by, + required int n, + bool inclusive = false, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(by); + var arg2 = cst_encode_usize(n); + var arg3 = cst_encode_bool(inclusive); + return wire.wire_Expr_str_split_exact(arg0, arg1, arg2, arg3); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrSplitExactConstMeta, + argValues: [that, by, n, inclusive], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrSplitExactConstMeta => const TaskConstMeta( + debugName: "Expr_str_split_exact", + argNames: ["that", "by", "n", "inclusive"], + ); + + @override + Expr exprStrSplitn( + {required Expr that, required Expr by, required int n, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(by); + var arg2 = cst_encode_usize(n); + return wire.wire_Expr_str_splitn(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrSplitnConstMeta, + argValues: [that, by, n], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrSplitnConstMeta => const TaskConstMeta( + debugName: "Expr_str_splitn", + argNames: ["that", "by", "n"], + ); + + @override + Expr exprStrStripChars( + {required Expr that, required Expr matches, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(matches); + return wire.wire_Expr_str_strip_chars(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrStripCharsConstMeta, + argValues: [that, matches], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrStripCharsConstMeta => const TaskConstMeta( + debugName: "Expr_str_strip_chars", + argNames: ["that", "matches"], + ); + + @override + Expr exprStrStripCharsEnd( + {required Expr that, required Expr matches, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(matches); + return wire.wire_Expr_str_strip_chars_end(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrStripCharsEndConstMeta, + argValues: [that, matches], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrStripCharsEndConstMeta => const TaskConstMeta( + debugName: "Expr_str_strip_chars_end", + argNames: ["that", "matches"], + ); + + @override + Expr exprStrStripCharsStart( + {required Expr that, required Expr matches, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(matches); + return wire.wire_Expr_str_strip_chars_start(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrStripCharsStartConstMeta, + argValues: [that, matches], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrStripCharsStartConstMeta => const TaskConstMeta( + debugName: "Expr_str_strip_chars_start", + argNames: ["that", "matches"], + ); + + @override + Expr exprStrStripPrefix( + {required Expr that, required Expr prefix, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(prefix); + return wire.wire_Expr_str_strip_prefix(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrStripPrefixConstMeta, + argValues: [that, prefix], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrStripPrefixConstMeta => const TaskConstMeta( + debugName: "Expr_str_strip_prefix", + argNames: ["that", "prefix"], + ); + + @override + Expr exprStrStripSuffix( + {required Expr that, required Expr suffix, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_expr(suffix); + return wire.wire_Expr_str_strip_suffix(arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrStripSuffixConstMeta, + argValues: [that, suffix], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrStripSuffixConstMeta => const TaskConstMeta( + debugName: "Expr_str_strip_suffix", + argNames: ["that", "suffix"], + ); + + @override + Expr exprStrToDate( + {required Expr that, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_opt_String(format); + var arg2 = cst_encode_bool(strict); + var arg3 = cst_encode_bool(exact); + var arg4 = cst_encode_bool(cache); + return wire.wire_Expr_str_to_date(arg0, arg1, arg2, arg3, arg4); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrToDateConstMeta, + argValues: [that, format, strict, exact, cache], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrToDateConstMeta => const TaskConstMeta( + debugName: "Expr_str_to_date", + argNames: ["that", "format", "strict", "exact", "cache"], + ); + + @override + Expr exprStrToDatetime( + {required Expr that, + TimeUnit? timeUnit, + String? timeZone, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_opt_box_autoadd_time_unit(timeUnit); + var arg2 = cst_encode_opt_String(timeZone); + var arg3 = cst_encode_opt_String(format); + var arg4 = cst_encode_bool(strict); + var arg5 = cst_encode_bool(exact); + var arg6 = cst_encode_bool(cache); + var arg7 = cst_encode_ambiguous(ambiguous); + return wire.wire_Expr_str_to_datetime( + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrToDatetimeConstMeta, + argValues: [ + that, + timeUnit, + timeZone, + format, + strict, + exact, + cache, + ambiguous + ], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrToDatetimeConstMeta => const TaskConstMeta( + debugName: "Expr_str_to_datetime", + argNames: [ + "that", + "timeUnit", + "timeZone", + "format", + "strict", + "exact", + "cache", + "ambiguous" + ], + ); + + @override + Expr exprStrToInteger( + {required Expr that, + required int base, + bool strict = true, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_u_32(base); + var arg2 = cst_encode_bool(strict); + return wire.wire_Expr_str_to_integer(arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrToIntegerConstMeta, + argValues: [that, base, strict], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrToIntegerConstMeta => const TaskConstMeta( + debugName: "Expr_str_to_integer", + argNames: ["that", "base", "strict"], + ); + + @override + Expr exprStrToLowercase({required Expr that, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + return wire.wire_Expr_str_to_lowercase(arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrToLowercaseConstMeta, + argValues: [that], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrToLowercaseConstMeta => const TaskConstMeta( + debugName: "Expr_str_to_lowercase", + argNames: ["that"], + ); + + @override + Expr exprStrToTime( + {required Expr that, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_opt_String(format); + var arg2 = cst_encode_bool(strict); + var arg3 = cst_encode_bool(exact); + var arg4 = cst_encode_bool(cache); + return wire.wire_Expr_str_to_time(arg0, arg1, arg2, arg3, arg4); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrToTimeConstMeta, + argValues: [that, format, strict, exact, cache], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrToTimeConstMeta => const TaskConstMeta( + debugName: "Expr_str_to_time", + argNames: ["that", "format", "strict", "exact", "cache"], + ); + + @override + Expr exprStrToUppercase({required Expr that, dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + return wire.wire_Expr_str_to_uppercase(arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrToUppercaseConstMeta, + argValues: [that], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrToUppercaseConstMeta => const TaskConstMeta( + debugName: "Expr_str_to_uppercase", + argNames: ["that"], + ); + + @override + Expr exprStrptime( + {required Expr that, + required DataType dtype, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + dynamic hint}) { + return handler.executeSync(SyncTask( + callFfi: () { + var arg0 = cst_encode_box_autoadd_expr(that); + var arg1 = cst_encode_box_autoadd_data_type(dtype); + var arg2 = cst_encode_opt_String(format); + var arg3 = cst_encode_bool(strict); + var arg4 = cst_encode_bool(exact); + var arg5 = cst_encode_bool(cache); + var arg6 = cst_encode_ambiguous(ambiguous); + return wire.wire_Expr_strptime( + arg0, arg1, arg2, arg3, arg4, arg5, arg6); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_expr, + decodeErrorData: null, + ), + constMeta: kExprStrptimeConstMeta, + argValues: [that, dtype, format, strict, exact, cache, ambiguous], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kExprStrptimeConstMeta => const TaskConstMeta( + debugName: "Expr_strptime", + argNames: [ + "that", + "dtype", + "format", + "strict", + "exact", + "cache", + "ambiguous" + ], + ); + + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_PExpr => + wire.rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafePExpr; + + RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_PExpr => + wire.rust_arc_decrement_strong_count_RustOpaque_AssertUnwindSafePExpr; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_SpecialEqPSeries => wire + .rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafeSpecialEqPSeries; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_SpecialEqPSeries => wire + .rust_arc_decrement_strong_count_RustOpaque_AssertUnwindSafeSpecialEqPSeries; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_DataFrame => wire + .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockDataFrame; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_DataFrame => wire + .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockDataFrame; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_LazyFrame => wire + .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockLazyFrame; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_LazyFrame => wire + .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockLazyFrame; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_LazyGroupBy => wire + .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockLazyGroupBy; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_LazyGroupBy => wire + .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockLazyGroupBy; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_OptionSchema => wire + .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockOptionSchema; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_OptionSchema => wire + .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockOptionSchema; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_OptionVecSeries => wire + .rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockOptionVecSeries; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_OptionVecSeries => wire + .rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockOptionVecSeries; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_Schema => + wire.rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockSchema; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_Schema => + wire.rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockSchema; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_Series => + wire.rust_arc_increment_strong_count_RustOpaque_stdsyncRwLockSeries; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_Series => + wire.rust_arc_decrement_strong_count_RustOpaque_stdsyncRwLockSeries; RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_VecSeries => wire @@ -8776,6 +9753,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw.cstEncode(); } + @protected + int cst_encode_ambiguous(Ambiguous raw) { + return cst_encode_i_32(raw.index); + } + @protected bool cst_encode_bool(bool raw) { return raw; @@ -9033,6 +10015,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } + @protected + void sse_encode_ambiguous(Ambiguous self, SseSerializer serializer) { + sse_encode_i_32(self.index, serializer); + } + @protected void sse_encode_bool(bool self, SseSerializer serializer) { serializer.buffer.putUint8(self ? 1 : 0); diff --git a/packages/polars/lib/src/frb_generated.io.dart b/packages/polars/lib/src/frb_generated.io.dart index 333558f..7610782 100644 --- a/packages/polars/lib/src/frb_generated.io.dart +++ b/packages/polars/lib/src/frb_generated.io.dart @@ -12,6 +12,7 @@ import 'wrapper/df.dart'; import 'wrapper/entry.dart'; import 'wrapper/expr.dart'; import 'wrapper/series.dart'; +import 'wrapper/str.dart'; abstract class RustLibApiImplPlatform extends BaseApiImpl { RustLibApiImplPlatform({ @@ -1717,6 +1718,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected PlatformPointer cst_encode_RustOpaque_stdsyncRwLockSeries(Series raw); + @protected + int cst_encode_ambiguous(Ambiguous raw); + @protected bool cst_encode_bool(bool raw); @@ -1846,6 +1850,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_encode_agg_expr(AggExpr self, SseSerializer serializer); + @protected + void sse_encode_ambiguous(Ambiguous self, SseSerializer serializer); + @protected void sse_encode_bool(bool self, SseSerializer serializer); @@ -6504,6 +6511,648 @@ class RustLibWire implements BaseWire { late final _wire_Series_var_as_series = _wire_Series_var_as_seriesPtr .asFunction, int)>(); + WireSyncRust2DartDco wire_Expr_str_concat( + ffi.Pointer that, + ffi.Pointer delimiter, + bool ignore_nulls, + ) { + return _wire_Expr_str_concat( + that, + delimiter, + ignore_nulls, + ); + } + + late final _wire_Expr_str_concatPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool)>>('wire_Expr_str_concat'); + late final _wire_Expr_str_concat = _wire_Expr_str_concatPtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_contains( + ffi.Pointer that, + ffi.Pointer pat, + bool strict, + ) { + return _wire_Expr_str_contains( + that, + pat, + strict, + ); + } + + late final _wire_Expr_str_containsPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('wire_Expr_str_contains'); + late final _wire_Expr_str_contains = _wire_Expr_str_containsPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_contains_literal( + ffi.Pointer that, + ffi.Pointer pat, + ) { + return _wire_Expr_str_contains_literal( + that, + pat, + ); + } + + late final _wire_Expr_str_contains_literalPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_contains_literal'); + late final _wire_Expr_str_contains_literal = + _wire_Expr_str_contains_literalPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_count_matches( + ffi.Pointer that, + ffi.Pointer pat, + bool literal, + ) { + return _wire_Expr_str_count_matches( + that, + pat, + literal, + ); + } + + late final _wire_Expr_str_count_matchesPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool)>>('wire_Expr_str_count_matches'); + late final _wire_Expr_str_count_matches = + _wire_Expr_str_count_matchesPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_ends_with( + ffi.Pointer that, + ffi.Pointer pat, + ) { + return _wire_Expr_str_ends_with( + that, + pat, + ); + } + + late final _wire_Expr_str_ends_withPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_ends_with'); + late final _wire_Expr_str_ends_with = _wire_Expr_str_ends_withPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_explode( + ffi.Pointer that, + ) { + return _wire_Expr_str_explode( + that, + ); + } + + late final _wire_Expr_str_explodePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer)>>('wire_Expr_str_explode'); + late final _wire_Expr_str_explode = _wire_Expr_str_explodePtr + .asFunction)>(); + + WireSyncRust2DartDco wire_Expr_str_extract( + ffi.Pointer that, + ffi.Pointer pat, + int group_index, + ) { + return _wire_Expr_str_extract( + that, + pat, + group_index, + ); + } + + late final _wire_Expr_str_extractPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.UintPtr)>>('wire_Expr_str_extract'); + late final _wire_Expr_str_extract = _wire_Expr_str_extractPtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, int)>(); + + WireSyncRust2DartDco wire_Expr_str_extract_all( + ffi.Pointer that, + ffi.Pointer pat, + ) { + return _wire_Expr_str_extract_all( + that, + pat, + ); + } + + late final _wire_Expr_str_extract_allPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_extract_all'); + late final _wire_Expr_str_extract_all = + _wire_Expr_str_extract_allPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_len_bytes( + ffi.Pointer that, + ) { + return _wire_Expr_str_len_bytes( + that, + ); + } + + late final _wire_Expr_str_len_bytesPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer)>>('wire_Expr_str_len_bytes'); + late final _wire_Expr_str_len_bytes = _wire_Expr_str_len_bytesPtr + .asFunction)>(); + + WireSyncRust2DartDco wire_Expr_str_len_chars( + ffi.Pointer that, + ) { + return _wire_Expr_str_len_chars( + that, + ); + } + + late final _wire_Expr_str_len_charsPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer)>>('wire_Expr_str_len_chars'); + late final _wire_Expr_str_len_chars = _wire_Expr_str_len_charsPtr + .asFunction)>(); + + WireSyncRust2DartDco wire_Expr_str_replace( + ffi.Pointer that, + ffi.Pointer pat, + ffi.Pointer val, + bool literal, + ) { + return _wire_Expr_str_replace( + that, + pat, + val, + literal, + ); + } + + late final _wire_Expr_str_replacePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool)>>('wire_Expr_str_replace'); + late final _wire_Expr_str_replace = _wire_Expr_str_replacePtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_replace_all( + ffi.Pointer that, + ffi.Pointer pat, + ffi.Pointer val, + bool literal, + ) { + return _wire_Expr_str_replace_all( + that, + pat, + val, + literal, + ); + } + + late final _wire_Expr_str_replace_allPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool)>>('wire_Expr_str_replace_all'); + late final _wire_Expr_str_replace_all = + _wire_Expr_str_replace_allPtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_replace_n( + ffi.Pointer that, + ffi.Pointer pat, + ffi.Pointer val, + bool literal, + int n, + ) { + return _wire_Expr_str_replace_n( + that, + pat, + val, + literal, + n, + ); + } + + late final _wire_Expr_str_replace_nPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Int64)>>('wire_Expr_str_replace_n'); + late final _wire_Expr_str_replace_n = _wire_Expr_str_replace_nPtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, bool, int)>(); + + WireSyncRust2DartDco wire_Expr_str_slice( + ffi.Pointer that, + int start, + ffi.Pointer length, + ) { + return _wire_Expr_str_slice( + that, + start, + length, + ); + } + + late final _wire_Expr_str_slicePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, ffi.Int64, + ffi.Pointer)>>('wire_Expr_str_slice'); + late final _wire_Expr_str_slice = _wire_Expr_str_slicePtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, int, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_split( + ffi.Pointer that, + ffi.Pointer by, + bool inclusive, + ) { + return _wire_Expr_str_split( + that, + by, + inclusive, + ); + } + + late final _wire_Expr_str_splitPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, ffi.Bool)>>('wire_Expr_str_split'); + late final _wire_Expr_str_split = _wire_Expr_str_splitPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_split_exact( + ffi.Pointer that, + ffi.Pointer by, + int n, + bool inclusive, + ) { + return _wire_Expr_str_split_exact( + that, + by, + n, + inclusive, + ); + } + + late final _wire_Expr_str_split_exactPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.UintPtr, + ffi.Bool)>>('wire_Expr_str_split_exact'); + late final _wire_Expr_str_split_exact = + _wire_Expr_str_split_exactPtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, int, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_splitn( + ffi.Pointer that, + ffi.Pointer by, + int n, + ) { + return _wire_Expr_str_splitn( + that, + by, + n, + ); + } + + late final _wire_Expr_str_splitnPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.UintPtr)>>('wire_Expr_str_splitn'); + late final _wire_Expr_str_splitn = _wire_Expr_str_splitnPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer, int)>(); + + WireSyncRust2DartDco wire_Expr_str_strip_chars( + ffi.Pointer that, + ffi.Pointer matches, + ) { + return _wire_Expr_str_strip_chars( + that, + matches, + ); + } + + late final _wire_Expr_str_strip_charsPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_strip_chars'); + late final _wire_Expr_str_strip_chars = + _wire_Expr_str_strip_charsPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_strip_chars_end( + ffi.Pointer that, + ffi.Pointer matches, + ) { + return _wire_Expr_str_strip_chars_end( + that, + matches, + ); + } + + late final _wire_Expr_str_strip_chars_endPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_strip_chars_end'); + late final _wire_Expr_str_strip_chars_end = + _wire_Expr_str_strip_chars_endPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_strip_chars_start( + ffi.Pointer that, + ffi.Pointer matches, + ) { + return _wire_Expr_str_strip_chars_start( + that, + matches, + ); + } + + late final _wire_Expr_str_strip_chars_startPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_strip_chars_start'); + late final _wire_Expr_str_strip_chars_start = + _wire_Expr_str_strip_chars_startPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_strip_prefix( + ffi.Pointer that, + ffi.Pointer prefix, + ) { + return _wire_Expr_str_strip_prefix( + that, + prefix, + ); + } + + late final _wire_Expr_str_strip_prefixPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_strip_prefix'); + late final _wire_Expr_str_strip_prefix = + _wire_Expr_str_strip_prefixPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_strip_suffix( + ffi.Pointer that, + ffi.Pointer suffix, + ) { + return _wire_Expr_str_strip_suffix( + that, + suffix, + ); + } + + late final _wire_Expr_str_strip_suffixPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer)>>('wire_Expr_str_strip_suffix'); + late final _wire_Expr_str_strip_suffix = + _wire_Expr_str_strip_suffixPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, ffi.Pointer)>(); + + WireSyncRust2DartDco wire_Expr_str_to_date( + ffi.Pointer that, + ffi.Pointer format, + bool strict, + bool exact, + bool cache, + ) { + return _wire_Expr_str_to_date( + that, + format, + strict, + exact, + cache, + ); + } + + late final _wire_Expr_str_to_datePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Bool)>>('wire_Expr_str_to_date'); + late final _wire_Expr_str_to_date = _wire_Expr_str_to_datePtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, bool, bool, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_to_datetime( + ffi.Pointer that, + ffi.Pointer time_unit, + ffi.Pointer time_zone, + ffi.Pointer format, + bool strict, + bool exact, + bool cache, + int ambiguous, + ) { + return _wire_Expr_str_to_datetime( + that, + time_unit, + time_zone, + format, + strict, + exact, + cache, + ambiguous, + ); + } + + late final _wire_Expr_str_to_datetimePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Bool, + ffi.Int32)>>('wire_Expr_str_to_datetime'); + late final _wire_Expr_str_to_datetime = + _wire_Expr_str_to_datetimePtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + bool, + bool, + bool, + int)>(); + + WireSyncRust2DartDco wire_Expr_str_to_integer( + ffi.Pointer that, + int base, + bool strict, + ) { + return _wire_Expr_str_to_integer( + that, + base, + strict, + ); + } + + late final _wire_Expr_str_to_integerPtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function(ffi.Pointer, ffi.Uint32, + ffi.Bool)>>('wire_Expr_str_to_integer'); + late final _wire_Expr_str_to_integer = + _wire_Expr_str_to_integerPtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, int, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_to_lowercase( + ffi.Pointer that, + ) { + return _wire_Expr_str_to_lowercase( + that, + ); + } + + late final _wire_Expr_str_to_lowercasePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer)>>('wire_Expr_str_to_lowercase'); + late final _wire_Expr_str_to_lowercase = _wire_Expr_str_to_lowercasePtr + .asFunction)>(); + + WireSyncRust2DartDco wire_Expr_str_to_time( + ffi.Pointer that, + ffi.Pointer format, + bool strict, + bool exact, + bool cache, + ) { + return _wire_Expr_str_to_time( + that, + format, + strict, + exact, + cache, + ); + } + + late final _wire_Expr_str_to_timePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Bool)>>('wire_Expr_str_to_time'); + late final _wire_Expr_str_to_time = _wire_Expr_str_to_timePtr.asFunction< + WireSyncRust2DartDco Function(ffi.Pointer, + ffi.Pointer, bool, bool, bool)>(); + + WireSyncRust2DartDco wire_Expr_str_to_uppercase( + ffi.Pointer that, + ) { + return _wire_Expr_str_to_uppercase( + that, + ); + } + + late final _wire_Expr_str_to_uppercasePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer)>>('wire_Expr_str_to_uppercase'); + late final _wire_Expr_str_to_uppercase = _wire_Expr_str_to_uppercasePtr + .asFunction)>(); + + WireSyncRust2DartDco wire_Expr_strptime( + ffi.Pointer that, + ffi.Pointer dtype, + ffi.Pointer format, + bool strict, + bool exact, + bool cache, + int ambiguous, + ) { + return _wire_Expr_strptime( + that, + dtype, + format, + strict, + exact, + cache, + ambiguous, + ); + } + + late final _wire_Expr_strptimePtr = _lookup< + ffi.NativeFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Bool, + ffi.Int32)>>('wire_Expr_strptime'); + late final _wire_Expr_strptime = _wire_Expr_strptimePtr.asFunction< + WireSyncRust2DartDco Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + bool, + bool, + bool, + int)>(); + void rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafePExpr( ffi.Pointer ptr, ) { diff --git a/packages/polars/lib/src/str.dart b/packages/polars/lib/src/str.dart new file mode 100644 index 0000000..c2ae33d --- /dev/null +++ b/packages/polars/lib/src/str.dart @@ -0,0 +1,120 @@ +import '../polars.dart'; + +/// Sugar for `Expr.str*` methods. +/// +/// See [Strings](https://docs.pola.rs/user-guide/expressions/strings) for more details. +/// +/// Many functions in this namespace accept a `pat` parameter, which is parsed +/// as a regular expression except when the parameter `literal` is set to `true`. +class StrNamespace { + final Expr expr; + const StrNamespace(this.expr); + + Expr containsLiteral(Object? pat) => expr.strContainsLiteral(pat: pat.expr); + Expr contains(Object? pat, {bool strict = true}) => + expr.strContains(pat: pat.expr, strict: strict); + Expr endsWith(Object? pat) => expr.strEndsWith(pat: pat.expr); + Expr extract(String pat, {required int groupIndex}) => + expr.strExtract(pat: pat, groupIndex: groupIndex); + Expr extractAll(Object? pat) => expr.strExtractAll(pat: pat.expr); + Expr countMatches(Object? pat, {bool literal = false}) => + expr.strCountMatches(pat: pat.expr, literal: literal); + Expr concat(String delimiter, {bool ignoreNulls = true}) => + expr.strConcat(delimiter: delimiter, ignoreNulls: ignoreNulls); + Expr splitN({required Expr by, required int n}) => + expr.strSplitn(by: by, n: n); + Expr replace(Object? pat, Object? val, {bool literal = false}) => + expr.strReplace(pat: pat.expr, val: val.expr, literal: literal); + Expr replaceN( + Object? pat, + Object? val, { + required int n, + bool literal = false, + }) => + expr.strReplaceN(pat: pat.expr, val: val.expr, n: n, literal: literal); + Expr replaceAll(Object? pat, Object? val, {bool literal = false}) => + expr.strReplaceAll(pat: pat.expr, val: val.expr, literal: literal); + Expr stripChars(Object? matches) => expr.strStripChars(matches: matches.expr); + Expr stripCharsStart(Object? matches) => + expr.strStripCharsStart(matches: matches.expr); + Expr stripCharsEnd(Object? matches) => + expr.strStripCharsEnd(matches: matches.expr); + Expr stripPrefix(Object? prefix) => expr.strStripPrefix(prefix: prefix.expr); + Expr stripSuffix(Object? suffix) => expr.strStripSuffix(suffix: suffix.expr); + Expr get toLowercase => expr.strToLowercase(); + Expr get toUppercase => expr.strToUppercase(); + Expr toInteger({required int base, bool strict = true}) => + expr.strToInteger(base: base, strict: strict); + Expr get lenBytes => expr.strLenBytes(); + Expr get lenChars => expr.strLenChars(); + Expr slice(int start, int? length) => + expr.strSlice(start: start, length: length); + Expr get explode => expr.strExplode(); + + Expr strptime( + DataType dtype, { + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + }) => + expr.strptime( + dtype: dtype, + format: format, + strict: strict, + exact: exact, + cache: cache, + ambiguous: ambiguous, + ); + + Expr toDate({ + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + }) => + expr.strToDate( + format: format, + strict: strict, + exact: exact, + cache: cache, + ); + + Expr toDatetime({ + String? format, + TimeUnit? timeUnit, + String? timeZone, + }) => + expr.strToDatetime( + format: format, + timeUnit: timeUnit, + timeZone: timeZone, + ); + + Expr toTime({ + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + }) => + expr.strToTime( + format: format, + strict: strict, + exact: exact, + cache: cache, + ); + + Expr split({ + required Object? by, + bool inclusive = false, + }) => + expr.strSplit(by: by.expr, inclusive: inclusive); + + Expr splitExact({ + required Object? by, + required int n, + bool inclusive = false, + }) => + expr.strSplitExact(by: by.expr, n: n, inclusive: inclusive); +} diff --git a/packages/polars/lib/src/wrapper/expr.dart b/packages/polars/lib/src/wrapper/expr.dart index e793fea..0d29f4a 100644 --- a/packages/polars/lib/src/wrapper/expr.dart +++ b/packages/polars/lib/src/wrapper/expr.dart @@ -63,6 +63,12 @@ sealed class AggExpr with _$AggExpr { ) = AggExpr_Var; } +enum Ambiguous { + raise, + earliest, + latest, +} + enum ClosedWindow { left, right, @@ -764,6 +770,252 @@ sealed class Expr with _$Expr { sort: sort, parallel: parallel, ); + + Expr strConcat( + {required String delimiter, bool ignoreNulls = true, dynamic hint}) => + RustLib.instance.api.exprStrConcat( + that: this, + delimiter: delimiter, + ignoreNulls: ignoreNulls, + ); + + Expr strContains({required Expr pat, bool strict = true, dynamic hint}) => + RustLib.instance.api.exprStrContains( + that: this, + pat: pat, + strict: strict, + ); + + Expr strContainsLiteral({required Expr pat, dynamic hint}) => + RustLib.instance.api.exprStrContainsLiteral( + that: this, + pat: pat, + ); + + Expr strCountMatches( + {required Expr pat, bool literal = false, dynamic hint}) => + RustLib.instance.api.exprStrCountMatches( + that: this, + pat: pat, + literal: literal, + ); + + Expr strEndsWith({required Expr pat, dynamic hint}) => + RustLib.instance.api.exprStrEndsWith( + that: this, + pat: pat, + ); + + Expr strExplode({dynamic hint}) => RustLib.instance.api.exprStrExplode( + that: this, + ); + + Expr strExtract( + {required String pat, required int groupIndex, dynamic hint}) => + RustLib.instance.api.exprStrExtract( + that: this, + pat: pat, + groupIndex: groupIndex, + ); + + Expr strExtractAll({required Expr pat, dynamic hint}) => + RustLib.instance.api.exprStrExtractAll( + that: this, + pat: pat, + ); + + Expr strLenBytes({dynamic hint}) => RustLib.instance.api.exprStrLenBytes( + that: this, + ); + + Expr strLenChars({dynamic hint}) => RustLib.instance.api.exprStrLenChars( + that: this, + ); + + Expr strReplace( + {required Expr pat, + required Expr val, + bool literal = false, + dynamic hint}) => + RustLib.instance.api.exprStrReplace( + that: this, + pat: pat, + val: val, + literal: literal, + ); + + Expr strReplaceAll( + {required Expr pat, + required Expr val, + bool literal = false, + dynamic hint}) => + RustLib.instance.api.exprStrReplaceAll( + that: this, + pat: pat, + val: val, + literal: literal, + ); + + Expr strReplaceN( + {required Expr pat, + required Expr val, + bool literal = false, + required int n, + dynamic hint}) => + RustLib.instance.api.exprStrReplaceN( + that: this, + pat: pat, + val: val, + literal: literal, + n: n, + ); + + Expr strSlice({required int start, int? length, dynamic hint}) => + RustLib.instance.api.exprStrSlice( + that: this, + start: start, + length: length, + ); + + Expr strSplit({required Expr by, bool inclusive = false, dynamic hint}) => + RustLib.instance.api.exprStrSplit( + that: this, + by: by, + inclusive: inclusive, + ); + + Expr strSplitExact( + {required Expr by, + required int n, + bool inclusive = false, + dynamic hint}) => + RustLib.instance.api.exprStrSplitExact( + that: this, + by: by, + n: n, + inclusive: inclusive, + ); + + Expr strSplitn({required Expr by, required int n, dynamic hint}) => + RustLib.instance.api.exprStrSplitn( + that: this, + by: by, + n: n, + ); + + Expr strStripChars({required Expr matches, dynamic hint}) => + RustLib.instance.api.exprStrStripChars( + that: this, + matches: matches, + ); + + Expr strStripCharsEnd({required Expr matches, dynamic hint}) => + RustLib.instance.api.exprStrStripCharsEnd( + that: this, + matches: matches, + ); + + Expr strStripCharsStart({required Expr matches, dynamic hint}) => + RustLib.instance.api.exprStrStripCharsStart( + that: this, + matches: matches, + ); + + Expr strStripPrefix({required Expr prefix, dynamic hint}) => + RustLib.instance.api.exprStrStripPrefix( + that: this, + prefix: prefix, + ); + + Expr strStripSuffix({required Expr suffix, dynamic hint}) => + RustLib.instance.api.exprStrStripSuffix( + that: this, + suffix: suffix, + ); + + Expr strToDate( + {String? format, + bool strict = true, + bool exact = true, + bool cache = true, + dynamic hint}) => + RustLib.instance.api.exprStrToDate( + that: this, + format: format, + strict: strict, + exact: exact, + cache: cache, + ); + + Expr strToDatetime( + {TimeUnit? timeUnit, + String? timeZone, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + dynamic hint}) => + RustLib.instance.api.exprStrToDatetime( + that: this, + timeUnit: timeUnit, + timeZone: timeZone, + format: format, + strict: strict, + exact: exact, + cache: cache, + ambiguous: ambiguous, + ); + + Expr strToInteger({required int base, bool strict = true, dynamic hint}) => + RustLib.instance.api.exprStrToInteger( + that: this, + base: base, + strict: strict, + ); + + Expr strToLowercase({dynamic hint}) => + RustLib.instance.api.exprStrToLowercase( + that: this, + ); + + Expr strToTime( + {String? format, + bool strict = true, + bool exact = true, + bool cache = true, + dynamic hint}) => + RustLib.instance.api.exprStrToTime( + that: this, + format: format, + strict: strict, + exact: exact, + cache: cache, + ); + + Expr strToUppercase({dynamic hint}) => + RustLib.instance.api.exprStrToUppercase( + that: this, + ); + + /// - `dtype` A temporal data type, i.e. Date, DateTime, or Time. + Expr strptime( + {required DataType dtype, + String? format, + bool strict = true, + bool exact = true, + bool cache = true, + Ambiguous ambiguous = Ambiguous.raise, + dynamic hint}) => + RustLib.instance.api.exprStrptime( + that: this, + dtype: dtype, + format: format, + strict: strict, + exact: exact, + cache: cache, + ambiguous: ambiguous, + ); } class Field { diff --git a/packages/polars/lib/src/wrapper/str.dart b/packages/polars/lib/src/wrapper/str.dart new file mode 100644 index 0000000..4f6f941 --- /dev/null +++ b/packages/polars/lib/src/wrapper/str.dart @@ -0,0 +1,10 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.6. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../frb_generated.dart'; +import 'df.dart'; +import 'entry.dart'; +import 'expr.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; diff --git a/polars-wrapper/Cargo.toml b/polars-wrapper/Cargo.toml index c51e275..8070864 100644 --- a/polars-wrapper/Cargo.toml +++ b/polars-wrapper/Cargo.toml @@ -11,6 +11,7 @@ anyhow = "1.0.68" chrono = "0.4.23" chrono-tz = "0.8.1" flutter_rust_bridge = { version = "2.0.0-dev.6", features = ["chrono"], path = "../../flutter_rust_bridge/frb_rust" } +paste = "1.0.14" [dependencies.polars] version = "0.35.4" @@ -21,9 +22,5 @@ features = [ # additional features "lazy", "abs", "cum_agg", "product", "describe", "json", "dtype-datetime", "cross_join", "semi_anti_join", "rolling_window", "trigonometry", "round_series", - "log", "is_in" + "log", "is_in", "strings", "concat_str", "string_to_integer", "lazy_regex" ] - -[profile.release] -opt = "-s" -lto = "thin" diff --git a/polars-wrapper/include/polars_wrapper.h b/polars-wrapper/include/polars_wrapper.h index 573dada..20abdf5 100644 --- a/polars-wrapper/include/polars_wrapper.h +++ b/polars-wrapper/include/polars_wrapper.h @@ -1151,6 +1151,121 @@ WireSyncRust2DartDco wire_Series_unique(const void *that, bool maintain_order); WireSyncRust2DartDco wire_Series_var_as_series(const void *that, uint8_t ddof); +WireSyncRust2DartDco wire_Expr_str_concat(struct wire_cst_expr *that, + struct wire_cst_list_prim_u_8 *delimiter, + bool ignore_nulls); + +WireSyncRust2DartDco wire_Expr_str_contains(struct wire_cst_expr *that, + struct wire_cst_expr *pat, + bool strict); + +WireSyncRust2DartDco wire_Expr_str_contains_literal(struct wire_cst_expr *that, + struct wire_cst_expr *pat); + +WireSyncRust2DartDco wire_Expr_str_count_matches(struct wire_cst_expr *that, + struct wire_cst_expr *pat, + bool literal); + +WireSyncRust2DartDco wire_Expr_str_ends_with(struct wire_cst_expr *that, struct wire_cst_expr *pat); + +WireSyncRust2DartDco wire_Expr_str_explode(struct wire_cst_expr *that); + +WireSyncRust2DartDco wire_Expr_str_extract(struct wire_cst_expr *that, + struct wire_cst_list_prim_u_8 *pat, + uintptr_t group_index); + +WireSyncRust2DartDco wire_Expr_str_extract_all(struct wire_cst_expr *that, + struct wire_cst_expr *pat); + +WireSyncRust2DartDco wire_Expr_str_len_bytes(struct wire_cst_expr *that); + +WireSyncRust2DartDco wire_Expr_str_len_chars(struct wire_cst_expr *that); + +WireSyncRust2DartDco wire_Expr_str_replace(struct wire_cst_expr *that, + struct wire_cst_expr *pat, + struct wire_cst_expr *val, + bool literal); + +WireSyncRust2DartDco wire_Expr_str_replace_all(struct wire_cst_expr *that, + struct wire_cst_expr *pat, + struct wire_cst_expr *val, + bool literal); + +WireSyncRust2DartDco wire_Expr_str_replace_n(struct wire_cst_expr *that, + struct wire_cst_expr *pat, + struct wire_cst_expr *val, + bool literal, + int64_t n); + +WireSyncRust2DartDco wire_Expr_str_slice(struct wire_cst_expr *that, + int64_t start, + uint64_t *length); + +WireSyncRust2DartDco wire_Expr_str_split(struct wire_cst_expr *that, + struct wire_cst_expr *by, + bool inclusive); + +WireSyncRust2DartDco wire_Expr_str_split_exact(struct wire_cst_expr *that, + struct wire_cst_expr *by, + uintptr_t n, + bool inclusive); + +WireSyncRust2DartDco wire_Expr_str_splitn(struct wire_cst_expr *that, + struct wire_cst_expr *by, + uintptr_t n); + +WireSyncRust2DartDco wire_Expr_str_strip_chars(struct wire_cst_expr *that, + struct wire_cst_expr *matches); + +WireSyncRust2DartDco wire_Expr_str_strip_chars_end(struct wire_cst_expr *that, + struct wire_cst_expr *matches); + +WireSyncRust2DartDco wire_Expr_str_strip_chars_start(struct wire_cst_expr *that, + struct wire_cst_expr *matches); + +WireSyncRust2DartDco wire_Expr_str_strip_prefix(struct wire_cst_expr *that, + struct wire_cst_expr *prefix); + +WireSyncRust2DartDco wire_Expr_str_strip_suffix(struct wire_cst_expr *that, + struct wire_cst_expr *suffix); + +WireSyncRust2DartDco wire_Expr_str_to_date(struct wire_cst_expr *that, + struct wire_cst_list_prim_u_8 *format, + bool strict, + bool exact, + bool cache); + +WireSyncRust2DartDco wire_Expr_str_to_datetime(struct wire_cst_expr *that, + int32_t *time_unit, + struct wire_cst_list_prim_u_8 *time_zone, + struct wire_cst_list_prim_u_8 *format, + bool strict, + bool exact, + bool cache, + int32_t ambiguous); + +WireSyncRust2DartDco wire_Expr_str_to_integer(struct wire_cst_expr *that, + uint32_t base, + bool strict); + +WireSyncRust2DartDco wire_Expr_str_to_lowercase(struct wire_cst_expr *that); + +WireSyncRust2DartDco wire_Expr_str_to_time(struct wire_cst_expr *that, + struct wire_cst_list_prim_u_8 *format, + bool strict, + bool exact, + bool cache); + +WireSyncRust2DartDco wire_Expr_str_to_uppercase(struct wire_cst_expr *that); + +WireSyncRust2DartDco wire_Expr_strptime(struct wire_cst_expr *that, + struct wire_cst_data_type *dtype, + struct wire_cst_list_prim_u_8 *format, + bool strict, + bool exact, + bool cache, + int32_t ambiguous); + void rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafePExpr(const void *ptr); void rust_arc_decrement_strong_count_RustOpaque_AssertUnwindSafePExpr(const void *ptr); @@ -1434,6 +1549,35 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_Expr_sin); dummy_var ^= ((int64_t) (void*) wire_Expr_sinh); dummy_var ^= ((int64_t) (void*) wire_Expr_sqrt); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_concat); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_contains); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_contains_literal); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_count_matches); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_ends_with); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_explode); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_extract); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_extract_all); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_len_bytes); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_len_chars); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_replace); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_replace_all); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_replace_n); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_slice); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_split); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_split_exact); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_splitn); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_strip_chars); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_strip_chars_end); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_strip_chars_start); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_strip_prefix); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_strip_suffix); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_to_date); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_to_datetime); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_to_integer); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_to_lowercase); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_to_time); + dummy_var ^= ((int64_t) (void*) wire_Expr_str_to_uppercase); + dummy_var ^= ((int64_t) (void*) wire_Expr_strptime); dummy_var ^= ((int64_t) (void*) wire_Expr_tan); dummy_var ^= ((int64_t) (void*) wire_Expr_tanh); dummy_var ^= ((int64_t) (void*) wire_Expr_to_dot); diff --git a/polars-wrapper/src/bridge.io.rs b/polars-wrapper/src/bridge.io.rs index 70ac939..ccfe307 100644 --- a/polars-wrapper/src/bridge.io.rs +++ b/polars-wrapper/src/bridge.io.rs @@ -2902,6 +2902,269 @@ pub extern "C" fn wire_Series_var_as_series( wire_Series_var_as_series_impl(that, ddof) } +#[no_mangle] +pub extern "C" fn wire_Expr_str_concat( + that: *mut wire_cst_expr, + delimiter: *mut wire_cst_list_prim_u_8, + ignore_nulls: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_concat_impl(that, delimiter, ignore_nulls) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_contains( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, + strict: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_contains_impl(that, pat, strict) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_contains_literal( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_contains_literal_impl(that, pat) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_count_matches( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, + literal: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_count_matches_impl(that, pat, literal) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_ends_with( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_ends_with_impl(that, pat) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_explode( + that: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_explode_impl(that) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_extract( + that: *mut wire_cst_expr, + pat: *mut wire_cst_list_prim_u_8, + group_index: usize, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_extract_impl(that, pat, group_index) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_extract_all( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_extract_all_impl(that, pat) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_len_bytes( + that: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_len_bytes_impl(that) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_len_chars( + that: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_len_chars_impl(that) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_replace( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, + val: *mut wire_cst_expr, + literal: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_replace_impl(that, pat, val, literal) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_replace_all( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, + val: *mut wire_cst_expr, + literal: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_replace_all_impl(that, pat, val, literal) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_replace_n( + that: *mut wire_cst_expr, + pat: *mut wire_cst_expr, + val: *mut wire_cst_expr, + literal: bool, + n: i64, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_replace_n_impl(that, pat, val, literal, n) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_slice( + that: *mut wire_cst_expr, + start: i64, + length: *mut u64, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_slice_impl(that, start, length) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_split( + that: *mut wire_cst_expr, + by: *mut wire_cst_expr, + inclusive: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_split_impl(that, by, inclusive) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_split_exact( + that: *mut wire_cst_expr, + by: *mut wire_cst_expr, + n: usize, + inclusive: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_split_exact_impl(that, by, n, inclusive) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_splitn( + that: *mut wire_cst_expr, + by: *mut wire_cst_expr, + n: usize, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_splitn_impl(that, by, n) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_strip_chars( + that: *mut wire_cst_expr, + matches: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_strip_chars_impl(that, matches) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_strip_chars_end( + that: *mut wire_cst_expr, + matches: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_strip_chars_end_impl(that, matches) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_strip_chars_start( + that: *mut wire_cst_expr, + matches: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_strip_chars_start_impl(that, matches) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_strip_prefix( + that: *mut wire_cst_expr, + prefix: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_strip_prefix_impl(that, prefix) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_strip_suffix( + that: *mut wire_cst_expr, + suffix: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_strip_suffix_impl(that, suffix) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_to_date( + that: *mut wire_cst_expr, + format: *mut wire_cst_list_prim_u_8, + strict: bool, + exact: bool, + cache: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_to_date_impl(that, format, strict, exact, cache) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_to_datetime( + that: *mut wire_cst_expr, + time_unit: *mut i32, + time_zone: *mut wire_cst_list_prim_u_8, + format: *mut wire_cst_list_prim_u_8, + strict: bool, + exact: bool, + cache: bool, + ambiguous: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_to_datetime_impl( + that, time_unit, time_zone, format, strict, exact, cache, ambiguous, + ) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_to_integer( + that: *mut wire_cst_expr, + base: u32, + strict: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_to_integer_impl(that, base, strict) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_to_lowercase( + that: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_to_lowercase_impl(that) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_to_time( + that: *mut wire_cst_expr, + format: *mut wire_cst_list_prim_u_8, + strict: bool, + exact: bool, + cache: bool, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_to_time_impl(that, format, strict, exact, cache) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_str_to_uppercase( + that: *mut wire_cst_expr, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_str_to_uppercase_impl(that) +} + +#[no_mangle] +pub extern "C" fn wire_Expr_strptime( + that: *mut wire_cst_expr, + dtype: *mut wire_cst_data_type, + format: *mut wire_cst_list_prim_u_8, + strict: bool, + exact: bool, + cache: bool, + ambiguous: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire_Expr_strptime_impl(that, dtype, format, strict, exact, cache, ambiguous) +} + #[no_mangle] pub extern "C" fn rust_arc_increment_strong_count_RustOpaque_AssertUnwindSafePExpr( ptr: *const std::ffi::c_void, diff --git a/polars-wrapper/src/bridge.rs b/polars-wrapper/src/bridge.rs index 5475b7c..a782ca6 100644 --- a/polars-wrapper/src/bridge.rs +++ b/polars-wrapper/src/bridge.rs @@ -5209,6 +5209,700 @@ fn wire_Series_var_as_series_impl( }, ) } +fn wire_Expr_str_concat_impl( + that: impl CstDecode + core::panic::UnwindSafe, + delimiter: impl CstDecode + core::panic::UnwindSafe, + ignore_nulls: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_concat", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_delimiter = delimiter.cst_decode(); + let api_ignore_nulls = ignore_nulls.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_concat( + &api_that, + api_delimiter, + api_ignore_nulls, + )) + })()) + }, + ) +} +fn wire_Expr_str_contains_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, + strict: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_contains", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + let api_strict = strict.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_contains( + &api_that, api_pat, api_strict, + )) + })()) + }, + ) +} +fn wire_Expr_str_contains_literal_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_contains_literal", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_contains_literal( + &api_that, api_pat, + )) + })()) + }, + ) +} +fn wire_Expr_str_count_matches_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, + literal: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_count_matches", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + let api_literal = literal.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_count_matches( + &api_that, + api_pat, + api_literal, + )) + })()) + }, + ) +} +fn wire_Expr_str_ends_with_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_ends_with", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_ends_with( + &api_that, api_pat, + )) + })()) + }, + ) +} +fn wire_Expr_str_explode_impl( + that: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_explode", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_explode(&api_that)) + })()) + }, + ) +} +fn wire_Expr_str_extract_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, + group_index: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_extract", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + let api_group_index = group_index.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_extract( + &api_that, + api_pat, + api_group_index, + )) + })()) + }, + ) +} +fn wire_Expr_str_extract_all_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_extract_all", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_extract_all( + &api_that, api_pat, + )) + })()) + }, + ) +} +fn wire_Expr_str_len_bytes_impl( + that: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_len_bytes", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_len_bytes(&api_that)) + })()) + }, + ) +} +fn wire_Expr_str_len_chars_impl( + that: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_len_chars", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_len_chars(&api_that)) + })()) + }, + ) +} +fn wire_Expr_str_replace_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, + val: impl CstDecode + core::panic::UnwindSafe, + literal: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_replace", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + let api_val = val.cst_decode(); + let api_literal = literal.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_replace( + &api_that, + api_pat, + api_val, + api_literal, + )) + })()) + }, + ) +} +fn wire_Expr_str_replace_all_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, + val: impl CstDecode + core::panic::UnwindSafe, + literal: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_replace_all", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + let api_val = val.cst_decode(); + let api_literal = literal.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_replace_all( + &api_that, + api_pat, + api_val, + api_literal, + )) + })()) + }, + ) +} +fn wire_Expr_str_replace_n_impl( + that: impl CstDecode + core::panic::UnwindSafe, + pat: impl CstDecode + core::panic::UnwindSafe, + val: impl CstDecode + core::panic::UnwindSafe, + literal: impl CstDecode + core::panic::UnwindSafe, + n: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_replace_n", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_pat = pat.cst_decode(); + let api_val = val.cst_decode(); + let api_literal = literal.cst_decode(); + let api_n = n.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_replace_n( + &api_that, + api_pat, + api_val, + api_literal, + api_n, + )) + })()) + }, + ) +} +fn wire_Expr_str_slice_impl( + that: impl CstDecode + core::panic::UnwindSafe, + start: impl CstDecode + core::panic::UnwindSafe, + length: impl CstDecode> + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_slice", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_start = start.cst_decode(); + let api_length = length.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_slice( + &api_that, api_start, api_length, + )) + })()) + }, + ) +} +fn wire_Expr_str_split_impl( + that: impl CstDecode + core::panic::UnwindSafe, + by: impl CstDecode + core::panic::UnwindSafe, + inclusive: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_split", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_by = by.cst_decode(); + let api_inclusive = inclusive.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_split( + &api_that, + api_by, + api_inclusive, + )) + })()) + }, + ) +} +fn wire_Expr_str_split_exact_impl( + that: impl CstDecode + core::panic::UnwindSafe, + by: impl CstDecode + core::panic::UnwindSafe, + n: impl CstDecode + core::panic::UnwindSafe, + inclusive: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_split_exact", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_by = by.cst_decode(); + let api_n = n.cst_decode(); + let api_inclusive = inclusive.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_split_exact( + &api_that, + api_by, + api_n, + api_inclusive, + )) + })()) + }, + ) +} +fn wire_Expr_str_splitn_impl( + that: impl CstDecode + core::panic::UnwindSafe, + by: impl CstDecode + core::panic::UnwindSafe, + n: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_splitn", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_by = by.cst_decode(); + let api_n = n.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_splitn( + &api_that, api_by, api_n, + )) + })()) + }, + ) +} +fn wire_Expr_str_strip_chars_impl( + that: impl CstDecode + core::panic::UnwindSafe, + matches: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_strip_chars", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_matches = matches.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_strip_chars( + &api_that, + api_matches, + )) + })()) + }, + ) +} +fn wire_Expr_str_strip_chars_end_impl( + that: impl CstDecode + core::panic::UnwindSafe, + matches: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_strip_chars_end", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_matches = matches.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_strip_chars_end( + &api_that, + api_matches, + )) + })()) + }, + ) +} +fn wire_Expr_str_strip_chars_start_impl( + that: impl CstDecode + core::panic::UnwindSafe, + matches: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_strip_chars_start", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_matches = matches.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_strip_chars_start( + &api_that, + api_matches, + )) + })()) + }, + ) +} +fn wire_Expr_str_strip_prefix_impl( + that: impl CstDecode + core::panic::UnwindSafe, + prefix: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_strip_prefix", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_prefix = prefix.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_strip_prefix( + &api_that, api_prefix, + )) + })()) + }, + ) +} +fn wire_Expr_str_strip_suffix_impl( + that: impl CstDecode + core::panic::UnwindSafe, + suffix: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_strip_suffix", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_suffix = suffix.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_strip_suffix( + &api_that, api_suffix, + )) + })()) + }, + ) +} +fn wire_Expr_str_to_date_impl( + that: impl CstDecode + core::panic::UnwindSafe, + format: impl CstDecode> + core::panic::UnwindSafe, + strict: impl CstDecode + core::panic::UnwindSafe, + exact: impl CstDecode + core::panic::UnwindSafe, + cache: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_to_date", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_format = format.cst_decode(); + let api_strict = strict.cst_decode(); + let api_exact = exact.cst_decode(); + let api_cache = cache.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_to_date( + &api_that, api_format, api_strict, api_exact, api_cache, + )) + })()) + }, + ) +} +fn wire_Expr_str_to_datetime_impl( + that: impl CstDecode + core::panic::UnwindSafe, + time_unit: impl CstDecode> + core::panic::UnwindSafe, + time_zone: impl CstDecode> + core::panic::UnwindSafe, + format: impl CstDecode> + core::panic::UnwindSafe, + strict: impl CstDecode + core::panic::UnwindSafe, + exact: impl CstDecode + core::panic::UnwindSafe, + cache: impl CstDecode + core::panic::UnwindSafe, + ambiguous: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_to_datetime", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_time_unit = time_unit.cst_decode(); + let api_time_zone = time_zone.cst_decode(); + let api_format = format.cst_decode(); + let api_strict = strict.cst_decode(); + let api_exact = exact.cst_decode(); + let api_cache = cache.cst_decode(); + let api_ambiguous = ambiguous.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_to_datetime( + &api_that, + api_time_unit, + api_time_zone, + api_format, + api_strict, + api_exact, + api_cache, + api_ambiguous, + )) + })()) + }, + ) +} +fn wire_Expr_str_to_integer_impl( + that: impl CstDecode + core::panic::UnwindSafe, + base: impl CstDecode + core::panic::UnwindSafe, + strict: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_to_integer", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_base = base.cst_decode(); + let api_strict = strict.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_to_integer( + &api_that, api_base, api_strict, + )) + })()) + }, + ) +} +fn wire_Expr_str_to_lowercase_impl( + that: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_to_lowercase", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_to_lowercase(&api_that)) + })()) + }, + ) +} +fn wire_Expr_str_to_time_impl( + that: impl CstDecode + core::panic::UnwindSafe, + format: impl CstDecode> + core::panic::UnwindSafe, + strict: impl CstDecode + core::panic::UnwindSafe, + exact: impl CstDecode + core::panic::UnwindSafe, + cache: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_to_time", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_format = format.cst_decode(); + let api_strict = strict.cst_decode(); + let api_exact = exact.cst_decode(); + let api_cache = cache.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_to_time( + &api_that, api_format, api_strict, api_exact, api_cache, + )) + })()) + }, + ) +} +fn wire_Expr_str_to_uppercase_impl( + that: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_str_to_uppercase", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::str_to_uppercase(&api_that)) + })()) + }, + ) +} +fn wire_Expr_strptime_impl( + that: impl CstDecode + core::panic::UnwindSafe, + dtype: impl CstDecode + core::panic::UnwindSafe, + format: impl CstDecode> + core::panic::UnwindSafe, + strict: impl CstDecode + core::panic::UnwindSafe, + exact: impl CstDecode + core::panic::UnwindSafe, + cache: impl CstDecode + core::panic::UnwindSafe, + ambiguous: impl CstDecode + core::panic::UnwindSafe, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Expr_strptime", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let api_that = that.cst_decode(); + let api_dtype = dtype.cst_decode(); + let api_format = format.cst_decode(); + let api_strict = strict.cst_decode(); + let api_exact = exact.cst_decode(); + let api_cache = cache.cst_decode(); + let api_ambiguous = ambiguous.cst_decode(); + transform_result_dco((move || { + Result::<_, ()>::Ok(crate::wrapper::expr::Expr::strptime( + &api_that, + api_dtype, + api_format, + api_strict, + api_exact, + api_cache, + api_ambiguous, + )) + })()) + }, + ) +} // Section: wrapper_structs @@ -5287,6 +5981,16 @@ const _: fn() = || { // Section: dart2rust +impl CstDecode for i32 { + fn cst_decode(self) -> crate::wrapper::expr::Ambiguous { + match self { + 0 => crate::wrapper::expr::Ambiguous::Raise, + 1 => crate::wrapper::expr::Ambiguous::Earliest, + 2 => crate::wrapper::expr::Ambiguous::Latest, + _ => unreachable!("Invalid variant for Ambiguous: {}", self), + } + } +} impl CstDecode for bool { fn cst_decode(self) -> bool { self @@ -5596,6 +6300,18 @@ impl SseDecode for crate::wrapper::expr::AggExpr { } } +impl SseDecode for crate::wrapper::expr::Ambiguous { + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::wrapper::expr::Ambiguous::Raise, + 1 => crate::wrapper::expr::Ambiguous::Earliest, + 2 => crate::wrapper::expr::Ambiguous::Latest, + _ => unreachable!("Invalid variant for Ambiguous: {}", inner), + }; + } +} + impl SseDecode for bool { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { deserializer.cursor.read_u8().unwrap() != 0 diff --git a/polars-wrapper/src/wrapper.rs b/polars-wrapper/src/wrapper.rs index fb3080e..39c88f2 100644 --- a/polars-wrapper/src/wrapper.rs +++ b/polars-wrapper/src/wrapper.rs @@ -6,6 +6,7 @@ pub(crate) mod series; pub(crate) mod df; pub(crate) mod entry; +pub(crate) mod str; mod util; pub(crate) mod prelude { diff --git a/polars-wrapper/src/wrapper/expr.rs b/polars-wrapper/src/wrapper/expr.rs index ea763ad..e8d76e5 100644 --- a/polars-wrapper/src/wrapper/expr.rs +++ b/polars-wrapper/src/wrapper/expr.rs @@ -1055,3 +1055,21 @@ impl From for Excluded { } } } + +pub enum Ambiguous { + Raise, + Earliest, + Latest, +} + +impl Ambiguous { + pub(crate) fn into_expr(self) -> PExpr { + match self { + Self::Raise => PExpr::Literal(polars::prelude::LiteralValue::Utf8("raise".into())), + Self::Earliest => { + PExpr::Literal(polars::prelude::LiteralValue::Utf8("earliest".into())) + } + Self::Latest => PExpr::Literal(polars::prelude::LiteralValue::Utf8("latest".into())), + } + } +} diff --git a/polars-wrapper/src/wrapper/str.rs b/polars-wrapper/src/wrapper/str.rs new file mode 100644 index 0000000..603b7d6 --- /dev/null +++ b/polars-wrapper/src/wrapper/str.rs @@ -0,0 +1,141 @@ +use flutter_rust_bridge::frb; +use polars::{datatypes::TimeUnit, lazy::dsl::StrptimeOptions}; + +use super::{ + df::{DataType, PExpr}, + expr::{Ambiguous, Expr}, +}; + +macro_rules! delegate_str { + ($( $(#[$attribute:meta])* $fn:ident(self $(,)? $($param:ident : $(#[$conv:ident])? $ty:ty $(= $default:expr)? ),*) -> $output:ty; )*) => {paste::paste!{$( + $(#[$attribute])* + pub fn [](self, $($(#[frb(default = $default)])? $param : $ty),*) -> $output { + <$output>::from(self.into_internal().str().$fn($($param $(.$conv())?),*)) + } + )*}}; +} +impl Expr { + delegate_str! { + #[frb(sync)] contains_literal(self, pat: #[into] Expr) -> Expr; + #[frb(sync)] contains(self, pat: #[into] Expr, strict: bool = true) -> Expr; + #[frb(sync)] ends_with(self, pat: #[into] Expr) -> Expr; + #[frb(sync)] extract(self, pat: #[as_str] String, group_index: usize) -> Expr; + #[frb(sync)] extract_all(self, pat: #[into] Expr) -> Expr; + #[frb(sync)] count_matches(self, pat: #[into] Expr, literal: bool = false) -> Expr; + #[frb(sync)] concat(self, delimiter: #[as_str] String, ignore_nulls: bool = true) -> Expr; + #[frb(sync)] splitn(self, by: #[into] Expr, n: usize) -> Expr; + #[frb(sync)] replace(self, pat: #[into] Expr, val: #[into] Expr, literal: bool = false) -> Expr; + #[frb(sync)] replace_n(self, pat: #[into] Expr, val: #[into] Expr, literal: bool = false, n: i64) -> Expr; + #[frb(sync)] replace_all(self, pat: #[into] Expr, val: #[into] Expr, literal: bool = false) -> Expr; + #[frb(sync)] strip_chars(self, matches: #[into] Expr) -> Expr; + #[frb(sync)] strip_chars_start(self, matches: #[into] Expr) -> Expr; + #[frb(sync)] strip_chars_end(self, matches: #[into] Expr) -> Expr; + #[frb(sync)] strip_prefix(self, prefix: #[into] Expr) -> Expr; + #[frb(sync)] strip_suffix(self, suffix: #[into] Expr) -> Expr; + #[frb(sync)] to_lowercase(self) -> Expr; + #[frb(sync)] to_uppercase(self) -> Expr; + #[frb(sync)] to_integer(self, base: u32, strict: bool = true) -> Expr; + #[frb(sync)] len_bytes(self) -> Expr; + #[frb(sync)] len_chars(self) -> Expr; + #[frb(sync)] slice(self, start: i64, length: Option) -> Expr; + #[frb(sync)] explode(self) -> Expr; + } + /// - `dtype` A temporal data type, i.e. Date, DateTime, or Time. + #[frb(sync)] + pub fn strptime( + self, + dtype: DataType, + format: Option, + #[frb(default = true)] strict: bool, + #[frb(default = true)] exact: bool, + #[frb(default = true)] cache: bool, + #[frb(default = "Ambiguous.raise")] ambiguous: Ambiguous, + ) -> Expr { + Expr::from(self.into_internal().str().strptime( + dtype.into(), + StrptimeOptions { + format, + strict, + exact, + cache, + }, + ambiguous.into_expr(), + )) + } + #[frb(sync)] + pub fn str_to_date( + self, + format: Option, + #[frb(default = true)] strict: bool, + #[frb(default = true)] exact: bool, + #[frb(default = true)] cache: bool, + ) -> Expr { + Expr::from(self.into_internal().str().to_date(StrptimeOptions { + format, + strict, + exact, + cache, + })) + } + #[frb(sync)] + pub fn str_to_datetime( + self, + time_unit: Option, + time_zone: Option, + format: Option, + #[frb(default = true)] strict: bool, + #[frb(default = true)] exact: bool, + #[frb(default = true)] cache: bool, + #[frb(default = "Ambiguous.raise")] ambiguous: Ambiguous, + ) -> Expr { + Expr::from(self.into_internal().str().to_datetime( + time_unit, + time_zone, + StrptimeOptions { + format, + strict, + exact, + cache, + }, + ambiguous.into_expr(), + )) + } + #[frb(sync)] + pub fn str_to_time( + self, + format: Option, + #[frb(default = true)] strict: bool, + #[frb(default = true)] exact: bool, + #[frb(default = true)] cache: bool, + ) -> Expr { + Expr::from(self.into_internal().str().to_time(StrptimeOptions { + format, + strict, + exact, + cache, + })) + } + #[frb(sync)] + pub fn str_split(self, by: Expr, #[frb(default = false)] inclusive: bool) -> Expr { + let str = self.into_internal().str(); + if inclusive { + Expr::from(str.split_inclusive(by.into())) + } else { + Expr::from(str.split(by.into())) + } + } + #[frb(sync)] + pub fn str_split_exact( + self, + by: Expr, + n: usize, + #[frb(default = false)] inclusive: bool, + ) -> Expr { + let str = self.into_internal().str(); + if inclusive { + Expr::from(str.split_exact_inclusive(by.into(), n)) + } else { + Expr::from(str.split_exact(by.into(), n)) + } + } +}