From 0ae7f2b760176f838dd33be4b1079edb0f8afd63 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 08:48:08 +0200 Subject: [PATCH 01/26] adds changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53ca3a2b774..68f56f01948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +* Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/guides/miscellaneous/whats-new for what's changed in V2. +* Overhaul of the logging implementation, from an opinionated approach to a configurable one. Please consult the [documentation](https://fzyzcjy.github.io/flutter_rust_bridge/guides/logging) for more information. If you implemented logging yourself you might have to migrate your changes. + ## 2.10.0 * Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/guides/miscellaneous/whats-new for what's changed in V2. From 80b0c4ba2bbe8b13697ec26ce7807acdc89e3433 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:22:21 +0200 Subject: [PATCH 02/26] lint: inlines variables in format! --- .../config/internal_config_parser/generator_parser.rs | 3 +-- .../spec_generator/class/ty/enumeration_complex.rs | 11 ++++++----- .../api_dart/spec_generator/sanity_checker.rs | 5 ++--- .../codegen/generator/misc/struct_or_record.rs | 4 ++-- .../spec_generator/codec/cst/encoder/ty/structure.rs | 2 +- .../dart/spec_generator/codec/dco/decoder/ty/boxed.rs | 2 +- frb_codegen/src/library/codegen/ir/mir/default.rs | 2 +- frb_codegen/src/library/codegen/ir/mir/ident.rs | 2 +- frb_codegen/src/library/codegen/ir/mir/pack.rs | 2 +- frb_codegen/src/library/codegen/ir/mir/ty/delegate.rs | 2 +- frb_codegen/src/library/codegen/ir/misc/skip.rs | 2 +- .../transformer/function_frb_override_transformer.rs | 2 +- .../transformer/resolve_type_alias_transformer.rs | 2 +- .../hir/tree/transformer/pub_use_transformer.rs | 5 +---- frb_codegen/src/library/commands/cbindgen.rs | 4 ++-- frb_codegen/src/library/commands/command_runner.rs | 5 ++--- frb_codegen/src/library/commands/ffigen.rs | 2 +- frb_codegen/src/library/integration/integrator.rs | 2 +- .../src/library/internal/frb_rust_source_code.rs | 5 ++++- .../src/library/utils/dart_repository/dart_repo.rs | 5 ++--- .../library/utils/dart_repository/dart_toolchain.rs | 2 +- frb_codegen/src/library/utils/namespace.rs | 3 +-- frb_rust/src/handler/error.rs | 2 +- frb_rust/src/misc/logs.rs | 4 ++-- frb_rust/src/rust2dart/sender.rs | 6 +++--- 25 files changed, 41 insertions(+), 45 deletions(-) diff --git a/frb_codegen/src/library/codegen/config/internal_config_parser/generator_parser.rs b/frb_codegen/src/library/codegen/config/internal_config_parser/generator_parser.rs index 1a09018fb42..78c36dc443f 100644 --- a/frb_codegen/src/library/codegen/config/internal_config_parser/generator_parser.rs +++ b/frb_codegen/src/library/codegen/config/internal_config_parser/generator_parser.rs @@ -178,8 +178,7 @@ fn compute_dart_type_rename(config: &Config) -> anyhow::Result", - raw + "flutter_rust_bridge::for_generated::RustAutoOpaqueInner<{raw}>" ))?, ]) } diff --git a/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs b/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs index 08a269560fc..a006dd80f4e 100644 --- a/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs +++ b/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs @@ -92,12 +92,13 @@ impl EnumRefApiDartGenerator<'_> { .iter() .map(|field| { // If no split, default values are not valid. - let default = optional_boundary_index(&st.fields) - .is_some() - .then(|| { + let default = if optional_boundary_index(&st.fields).is_some() { + { generate_field_default(field, true, self.context.config.dart_enums_style) - }) - .unwrap_or_default(); + } + } else { + Default::default() + }; let comments = generate_dart_comments(&field.comments); let type_str = ApiDartGenerator::new(field.ty.clone(), self.context).dart_api_type(); diff --git a/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/sanity_checker.rs b/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/sanity_checker.rs index 6be307fe24c..960c3d6200f 100644 --- a/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/sanity_checker.rs +++ b/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/sanity_checker.rs @@ -17,12 +17,11 @@ pub(crate) fn sanity_check_class_name_duplicates( if !duplicate_class_names.is_empty() { const SKIP_ENV_VAR: &str = "FRB_DEBUG_SKIP_SANITY_CHECK_CLASS_NAME_DUPLICATES"; let message = format!( - "Will generate duplicated class names ({:?}). This is often because the type is auto inferred as both opaque and non-opaque. Try to add `#[frb(opaque)]` or `#[frb(non_opaque)]` to the struct, or change code that uses it.", - duplicate_class_names, + "Will generate duplicated class names ({duplicate_class_names:?}). This is often because the type is auto inferred as both opaque and non-opaque. Try to add `#[frb(opaque)]` or `#[frb(non_opaque)]` to the struct, or change code that uses it." ); if std::env::var(SKIP_ENV_VAR).is_ok() { - warn!("{}", message); + warn!("{message}",); } else { bail!( "{}Another way to debug is to temporarily set environment variable `{}=1` and check the generated code.", diff --git a/frb_codegen/src/library/codegen/generator/misc/struct_or_record.rs b/frb_codegen/src/library/codegen/generator/misc/struct_or_record.rs index 23a0a3f9550..1f1f7534c15 100644 --- a/frb_codegen/src/library/codegen/generator/misc/struct_or_record.rs +++ b/frb_codegen/src/library/codegen/generator/misc/struct_or_record.rs @@ -24,10 +24,10 @@ impl StructOrRecord { if is_field_named { field.name.rust_style(false).to_owned() } else { - format!("{}", index) + format!("{index}") } } - StructOrRecord::Record => format!("{}", index), + StructOrRecord::Record => format!("{index}"), }, } } diff --git a/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/cst/encoder/ty/structure.rs b/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/cst/encoder/ty/structure.rs index f513dc8ae10..8974b78d32a 100644 --- a/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/cst/encoder/ty/structure.rs +++ b/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/cst/encoder/ty/structure.rs @@ -65,7 +65,7 @@ impl<'a> GeneralizedStructGenerator<'a> { ) }) .join(","); - format!("return [{}].jsify()!;", values) + format!("return [{values}].jsify()!;") }), ..Default::default() } diff --git a/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/dco/decoder/ty/boxed.rs b/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/dco/decoder/ty/boxed.rs index 14a51a01b2f..30ef2b69f92 100644 --- a/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/dco/decoder/ty/boxed.rs +++ b/frb_codegen/src/library/codegen/generator/wire/dart/spec_generator/codec/dco/decoder/ty/boxed.rs @@ -30,7 +30,7 @@ impl WireDartCodecDcoGeneratorDecoderTrait for BoxedWireDartCodecDcoGenerator<'_ } // TODO merge with above Delegate(MirTypeDelegate::Time(time)) => { - format!("return dco_decode_Chrono_{}(raw);", time) + format!("return dco_decode_Chrono_{time}(raw);") } _ => gen_decode_simple_type_cast(self.mir.clone().into(), self.context), } diff --git a/frb_codegen/src/library/codegen/ir/mir/default.rs b/frb_codegen/src/library/codegen/ir/mir/default.rs index b5ddb77e441..b5a70e1c19e 100644 --- a/frb_codegen/src/library/codegen/ir/mir/default.rs +++ b/frb_codegen/src/library/codegen/ir/mir/default.rs @@ -10,7 +10,7 @@ pub enum MirDefaultValue { impl MirDefaultValue { pub(crate) fn to_dart_literal(&self) -> Cow { match self { - MirDefaultValue::String { content } => format!("r\"{}\"", content).into(), + MirDefaultValue::String { content } => format!("r\"{content}\"").into(), MirDefaultValue::Others { dart_literal } => dart_literal.into(), } } diff --git a/frb_codegen/src/library/codegen/ir/mir/ident.rs b/frb_codegen/src/library/codegen/ir/mir/ident.rs index 6fe426b2352..ff985f9877a 100644 --- a/frb_codegen/src/library/codegen/ir/mir/ident.rs +++ b/frb_codegen/src/library/codegen/ir/mir/ident.rs @@ -45,7 +45,7 @@ impl std::fmt::Display for MirIdent { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { fmt.write_str(&self.rust_style)?; if let Some(dart_style) = &self.dart_style { - write!(fmt, "(dart_style={})", dart_style)?; + write!(fmt, "(dart_style={dart_style})")?; } Ok(()) } diff --git a/frb_codegen/src/library/codegen/ir/mir/pack.rs b/frb_codegen/src/library/codegen/ir/mir/pack.rs index f7cd2c72013..c594a2c53f2 100644 --- a/frb_codegen/src/library/codegen/ir/mir/pack.rs +++ b/frb_codegen/src/library/codegen/ir/mir/pack.rs @@ -90,7 +90,7 @@ impl MirPackComputedCache { ( codec, mir_pack.distinct_types(Some(Box::new(move |codec_mode_pack| { - (codec_mode_pack.all().iter()).any(|c| *c == codec) + codec_mode_pack.all().contains(&codec) }))), ) }) diff --git a/frb_codegen/src/library/codegen/ir/mir/ty/delegate.rs b/frb_codegen/src/library/codegen/ir/mir/ty/delegate.rs index c7a98ffcb88..b2d4f181d23 100644 --- a/frb_codegen/src/library/codegen/ir/mir/ty/delegate.rs +++ b/frb_codegen/src/library/codegen/ir/mir/ty/delegate.rs @@ -173,7 +173,7 @@ impl MirTypeTrait for MirTypeDelegate { // "ZeroCopyBuffer_".to_owned() + &self.get_delegate().safe_ident() // } MirTypeDelegate::PrimitiveEnum(mir) => mir.mir.safe_ident(), - MirTypeDelegate::Time(mir) => format!("Chrono_{}", mir), + MirTypeDelegate::Time(mir) => format!("Chrono_{mir}"), // MirTypeDelegate::TimeList(mir) => format!("Chrono_{}List", mir), MirTypeDelegate::Uuid => "Uuid".to_owned(), // MirTypeDelegate::Uuids => "Uuids".to_owned(), diff --git a/frb_codegen/src/library/codegen/ir/misc/skip.rs b/frb_codegen/src/library/codegen/ir/misc/skip.rs index a2c1c076dce..8587edb5b1e 100644 --- a/frb_codegen/src/library/codegen/ir/misc/skip.rs +++ b/frb_codegen/src/library/codegen/ir/misc/skip.rs @@ -48,7 +48,7 @@ impl IrSkipReason { Self::Err => { "These functions have error during generation (see debug logs or enable `stop_on_error: true` for more details)".to_owned() } - _ => format!("These functions are ignored (category: {:?})", self) + _ => format!("These functions are ignored (category: {self:?})") }) } } diff --git a/frb_codegen/src/library/codegen/parser/hir/flat/transformer/function_frb_override_transformer.rs b/frb_codegen/src/library/codegen/parser/hir/flat/transformer/function_frb_override_transformer.rs index 9f1e612398f..7b18902cfa8 100644 --- a/frb_codegen/src/library/codegen/parser/hir/flat/transformer/function_frb_override_transformer.rs +++ b/frb_codegen/src/library/codegen/parser/hir/flat/transformer/function_frb_override_transformer.rs @@ -12,7 +12,7 @@ pub(crate) fn transform(mut pack: HirFlatPack) -> anyhow::Result { fn transform_function(function: &mut HirFlatFunction) -> anyhow::Result<()> { if let Some(func_name_stripped) = function.item_fn.name().strip_prefix(FRB_OVERRIDE_PREFIX) { - let attr_extra_str = format!(r###"#[frb(name = "{}")]"###, func_name_stripped); + let attr_extra_str = format!(r###"#[frb(name = "{func_name_stripped}")]"###); let attr_extra = parse_attribute(&attr_extra_str)?; function.sources.push(HirGenerationSource::FromFrbOverride); diff --git a/frb_codegen/src/library/codegen/parser/hir/flat/transformer/resolve_type_alias_transformer.rs b/frb_codegen/src/library/codegen/parser/hir/flat/transformer/resolve_type_alias_transformer.rs index ad82ac6fcba..9d0d4716751 100644 --- a/frb_codegen/src/library/codegen/parser/hir/flat/transformer/resolve_type_alias_transformer.rs +++ b/frb_codegen/src/library/codegen/parser/hir/flat/transformer/resolve_type_alias_transformer.rs @@ -81,7 +81,7 @@ pub(crate) fn resolve_type_aliases(src: HashMap) -> HashMap anyhow::Result< ), ..default_cbindgen_config }; - debug!("cbindgen config: {:#?}", config); + debug!("cbindgen config: {config:#?}"); cbindgen_raw(config, args.rust_crate_dir, c_output_path) } @@ -70,7 +70,7 @@ pub(crate) fn cbindgen_raw( c_output_path: &Path, ) -> anyhow::Result<()> { let parsed_crate_dir = parse_crate_dir(rust_crate_dir)?; - debug!("cbindgen parsed_crate_dir={}", parsed_crate_dir); + debug!("cbindgen parsed_crate_dir={parsed_crate_dir}"); #[allow(clippy::manual_inspect)] let bindings = cbindgen::generate_with_config(parsed_crate_dir, config).map_err(|e| { diff --git a/frb_codegen/src/library/commands/command_runner.rs b/frb_codegen/src/library/commands/command_runner.rs index 425dfa5bf25..440884f92b6 100644 --- a/frb_codegen/src/library/commands/command_runner.rs +++ b/frb_codegen/src/library/commands/command_runner.rs @@ -135,8 +135,7 @@ pub(crate) fn execute_command<'a>( } debug!( - "execute command: bin={} args={:?} current_dir={:?} cmd={:?}", - bin, args_display, current_dir, cmd + "execute command: bin={bin} args={args_display:?} current_dir={current_dir:?} cmd={cmd:?}" ); let result = cmd @@ -154,7 +153,7 @@ pub(crate) fn execute_command<'a>( if stdout.contains("fatal error") { // We do not care about details of this message // frb-coverage:ignore-start - warn!("See keywords such as `error` in command output. Maybe there is a problem? command={:?} stdout={:?}", cmd, stdout); + warn!("See keywords such as `error` in command output. Maybe there is a problem? command={cmd:?} stdout={stdout:?}"); // frb-coverage:ignore-end } } else if options.log_when_error.unwrap_or(true) { diff --git a/frb_codegen/src/library/commands/ffigen.rs b/frb_codegen/src/library/commands/ffigen.rs index 8ac5be68111..66062929cc6 100644 --- a/frb_codegen/src/library/commands/ffigen.rs +++ b/frb_codegen/src/library/commands/ffigen.rs @@ -96,7 +96,7 @@ pub(crate) fn ffigen_raw(config: &FfigenCommandConfig, dart_root: &Path) -> anyh &String::from_utf8_lossy(&res.stdout), &String::from_utf8_lossy(&res.stderr), )? { - warn!("{}", warning); + warn!("{warning}"); } Ok(()) diff --git a/frb_codegen/src/library/integration/integrator.rs b/frb_codegen/src/library/integration/integrator.rs index 9571cb722b9..ec201380127 100644 --- a/frb_codegen/src/library/integration/integrator.rs +++ b/frb_codegen/src/library/integration/integrator.rs @@ -32,7 +32,7 @@ pub fn integrate(config: IntegrateConfig) -> Result<()> { let rust_crate_name = config .rust_crate_name .clone() - .unwrap_or(format!("rust_lib_{}", dart_package_name)); + .unwrap_or(format!("rust_lib_{dart_package_name}")); info!("Overlay template onto project"); let replacements = compute_replacements(&config, &dart_package_name, &rust_crate_name); diff --git a/frb_codegen/src/library/internal/frb_rust_source_code.rs b/frb_codegen/src/library/internal/frb_rust_source_code.rs index 7658ce69702..098d8bf3166 100644 --- a/frb_codegen/src/library/internal/frb_rust_source_code.rs +++ b/frb_codegen/src/library/internal/frb_rust_source_code.rs @@ -32,7 +32,10 @@ pub(crate) fn generate_frb_rust_source_code(repo_base_dir: &Path) -> anyhow::Res ); fs::write(&path_target, text)?; - format_rust(&[path_target.clone()], path_target.parent().unwrap())?; + format_rust( + std::slice::from_ref(&path_target), + path_target.parent().unwrap(), + )?; Ok(()) } diff --git a/frb_codegen/src/library/utils/dart_repository/dart_repo.rs b/frb_codegen/src/library/utils/dart_repository/dart_repo.rs index 1738fdc7c46..a2107e5b2df 100644 --- a/frb_codegen/src/library/utils/dart_repository/dart_repo.rs +++ b/frb_codegen/src/library/utils/dart_repository/dart_repo.rs @@ -115,8 +115,7 @@ impl DartRepository { // This will stop the whole generator and tell the users, so we do not care about testing it // frb-coverage:ignore-start anyhow::Error::msg(format!( - "unable to parse {} version in {}: {:#}", - package, filename, e + "unable to parse {package} version in {filename}: {e:#}" )) // frb-coverage:ignore-end })? @@ -205,7 +204,7 @@ impl Display for DartPackageVersion { DartPackageVersion::Exact(v) => v.to_string(), DartPackageVersion::Range(v) => v.to_string(), }; - write!(f, "{}", str) + write!(f, "{str}") } } diff --git a/frb_codegen/src/library/utils/dart_repository/dart_toolchain.rs b/frb_codegen/src/library/utils/dart_repository/dart_toolchain.rs index 06a06abefb0..27bd92b9150 100644 --- a/frb_codegen/src/library/utils/dart_repository/dart_toolchain.rs +++ b/frb_codegen/src/library/utils/dart_repository/dart_toolchain.rs @@ -18,7 +18,7 @@ impl Display for DartToolchain { DartToolchain::Flutter => "flutter", } .to_string(); - write!(f, "{}", str) + write!(f, "{str}") } } diff --git a/frb_codegen/src/library/utils/namespace.rs b/frb_codegen/src/library/utils/namespace.rs index 9a5c1fd1f41..23f0b2ba49f 100644 --- a/frb_codegen/src/library/utils/namespace.rs +++ b/frb_codegen/src/library/utils/namespace.rs @@ -28,8 +28,7 @@ impl Namespace { // frb-coverage:ignore-start assert!( !joined_path.contains('\\'), - "joined_path={:?} seems weird", - joined_path + "joined_path={joined_path:?} seems weird", ); // frb-coverage:ignore-end Self { joined_path } diff --git a/frb_rust/src/handler/error.rs b/frb_rust/src/handler/error.rs index 952149d7bef..ea38a541119 100644 --- a/frb_rust/src/handler/error.rs +++ b/frb_rust/src/handler/error.rs @@ -33,7 +33,7 @@ pub(crate) fn error_to_string( .to_string(); let backtrace_string = backtrace .as_ref() - .map(|b| format!("{:?}", b)) + .map(|b| format!("{b:?}")) .unwrap_or_default(); err_string + &backtrace_string } diff --git a/frb_rust/src/misc/logs.rs b/frb_rust/src/misc/logs.rs index 4368825c5f8..30d54749f6f 100644 --- a/frb_rust/src/misc/logs.rs +++ b/frb_rust/src/misc/logs.rs @@ -6,13 +6,13 @@ pub(crate) fn log_warn_or_println(message: &str) { if log_enabled { #[cfg(feature = "log")] - log::warn!("{}", message); + log::warn!("{message}"); // frb-coverage:ignore-start // this is not reachable, so not coverable #[cfg(not(feature = "log"))] unreachable!(); // frb-coverage:ignore-end } else { - println!("{}", message); + println!("{message}"); } } diff --git a/frb_rust/src/rust2dart/sender.rs b/frb_rust/src/rust2dart/sender.rs index 1ccceef5c75..727d0ebdc33 100644 --- a/frb_rust/src/rust2dart/sender.rs +++ b/frb_rust/src/rust2dart/sender.rs @@ -37,7 +37,7 @@ pub struct Rust2DartSendError; impl fmt::Debug for Rust2DartSendError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self) + write!(f, "{self}") } } @@ -53,7 +53,7 @@ mod tests { #[test] fn test_rust2dart_send_error() { - assert!(format!("{}", Rust2DartSendError).contains("post message")); - assert!(format!("{:?}", Rust2DartSendError).contains("post message")); + assert!(format!("{Rust2DartSendError}").contains("post message")); + assert!(format!("{Rust2DartSendError:?}").contains("post message")); } } From a7d301966e689d3cadbbc86419875507268ca034 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:45:23 +0200 Subject: [PATCH 03/26] rewrites documentation --- website/docs/guides/how-to/logging.md | 402 ++++++++++++++++++++++---- 1 file changed, 349 insertions(+), 53 deletions(-) diff --git a/website/docs/guides/how-to/logging.md b/website/docs/guides/how-to/logging.md index 87ff3139176..cfe7e15ba42 100644 --- a/website/docs/guides/how-to/logging.md +++ b/website/docs/guides/how-to/logging.md @@ -1,89 +1,385 @@ # Logging -Since I have seen some questions asking how logging can be implemented with a Flutter + Rust application, here are some examples. +`flutter_rust_bridge` comes with out-of-the-box logging, but you can override it with your own as well. +More concretely, you can override the log outputting function with the one(s) of your logging framework(s) of choice, which will automatically log statements from Rust as well. -## Approach 1: Use the default one +Under the hood (and in a nutshell) our implementation uses the [Rust 'log' crate](https://crates.io/crates/log) and the [Dart 'logging' package](https://pub.dev/packages/logging), which are maintained by the respective language teams. -If using the template by `flutter_rust_bridge_codegen create/integrate`, the "print logs to console" is configured by default, -via the auto-generated call to `flutter_rust_bridge::setup_default_user_utils()`. +Log messages are sent via a FRB's Stream implementation from Rust to Dart. -Thus, you do not need to do anything :) +## Setup +### 1. add the logging dependency +First you need to add a dependency on the logging crate in your Cargo.toml file with `cargo add log` or by putting `log = "^0.4.20"` in your Cargo.toml file under the `[dependencies]` section. +If you start with a new project (`flutter_rust_bridge_codegen create` instead of `flutter_rust_bridge_codegen generate`) this dependency is already added for you. -## Example 2: Print logs to console +### 2. expose the generated StreamSink +Next, you need to expose a generated `StreamSink` so the logging code can find it. +If you have not disabled automatically configuring your `lib.rs` in your `flutter_rust_bridge.yaml` (with `add_mod_to_lib: false`) these lines are added for you. -```rust -fn setup_the_logger() { - #[cfg(target_os = "android")] - android_logger::init_once(android_logger::Config::default().with_max_level(LevelFilter::Trace)); +Otherwise, enter +``` +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +``` +into your project's `lib.rs`. - #[cfg(target_os = "ios")] - oslog::OsLogger::new("com.example.test").level_filter(LevelFilter::Trace).init().unwrap(); -} +Replace `frb_generated` in `crate::frb_generated::StreamSink` with the module path where you configured the generated files to go to, i.e. the value you set for `rust_output` in the `flutter_rust_bridge.yaml` configuration file. If you did not set this option `crate::frb_generated` is the correct default, no need to change this. + +### 3. activate logging +Finally, add the macro call `enable_frb_logging!();` in a **Rust** file that is part of your `rust_input` of your `flutter_rust_bridge.yaml` configuration, at any place outside of an item (e.g. function or struct). +You need to make it available via `use flutter_rust_bridge::enable_frb_logging;`. + +It needs to be there so the code generation is picking it up and generates the needed bridge code for connecting Rust and Dart for logging. + +### 4. customize the log function +Per default any log output is written to `stdout`, via `println!` in Rust. +You can provide your own log function, as described further down in `utilize a logging framework`. + +Note that this is needed, if you are developing a _Flutter_ application, as `stdout` is not shown. + +## How to use it + +All logs will be printed to `stdout`. + +You can issue log statements in Rust and Dart by following the usual way done in the respective 3rd party packages: + +In **Rust** simply call `log::info!()` (or any of the [log crate's log levels](https://docs.rs/log/latest/log/enum.Level.html)). + +In **Dart** you first need to initialise logging with a call to `final LOGGER = FRBLogger.initLogger()`. +If you do this call more than once an Exception is thrown. +This not only sets up logging for the Rust side, it returns a logger you can use to record log statements as well. + +Doing this in `main.dart`, preferably as a global variable `final LOGGER = FRBLogger.initLogger();`, is recommended, so no Rust log statement is executed before this setup. + +To get the logger handle after the initialization you can call `final LOGGER = FRBLogger.getLogger()`. +This is in turn calling `FRBDartLogger.getLogger()`, which you can call directly instead (they are effectively the same). + +In both calls (`.initLogger()` and `.getLogger()`) you can provide a `LoggerName` (which defaults to "FRBLogger"). + +To issue a log statement, you then call `LOGGER.info('Hello world');` (or other log levels) on that instance. +Note that in **Rust** code you use the [log crate's log levels](https://docs.rs/log/latest/log/enum.Level.html), while in **Dart** code you use a mixture of those and [Dart's logging package equivalents](https://pub.dev/documentation/logging/latest/logging/Level-class.html). + +All of Dart's logging package log levels are available, but the more exotic ones have been replaced with the more common levels used in Rust: +- FINE -> trace +- CONFIG -> debug +- SEVERE -> error +- SHOUT -> fatal + +While Rust's log crate captures the module, file and line number of the log statement, Dart's logging package does not. +Here it is idiomatic to get a new handle of the logger in each file, and give it a name that tells you where your log statement is originating from. +Usually one calls `final OTHER_LOGGER = Logger("other_logger");` from the library directly, but again, use `final OTHER_LOGGER = FRBLogger.getLogger("other_logger");` instead. + +## Customization + +There are three parameters that can be customized: +1. `name`: Name of the root (=first) logger on the Dart side (default: "FRBLogger"). +2. `maxLoglevel`: Maximum log level to be captured by Rust and Dart (default: "Info"). +3. `customLogFunction` The function to use for logging (default: `println!`). + +You can override the defaults by passing arguments to `enable_frb_logging!();` in your Rust code or `FRBLogger.initLogger()` in your Dart code. +The parameter names of these are the same for both languages. +Be aware that while the order doesn't matter in Dart, it matters in the Rust macro call! + +Avoid setting these parameters on both sides (Rust and Dart) at the same time. +The implementation will take the values set in Dart if `FRBLogger.initLogger()` is called before any subsequent `FRBLogger.getLogger();` call - otherwise, it takes the values set with `enable_frb_logging!();`. + +When you customize the logging in your Dart code with `FRBLogger.initLogger()`, the call returns an instance of a logger, which you can use. +There is no need for a call to `FRBLogger.getLogger();` (with the same name parameter), as this will return the same instance. + +### Change the root logger name + +To change the root logger name, either call `enable_frb_logging!(name = "My Name");` in Rust or `FRBLogger.initLogger(name = "My Name");` in Dart. +If you use the default and instantiate your logger in Dart with a specific name (e.g. `FRBLogger.getLogger("My Logger");`), log statements using this new named logger will display "my logger", but the root logger will retain its default name ("FRBLogger"). +Unless you want to get the root logger (with `FRBLogger.getLogger("FRBLogger")`) you might not notice the difference. + +### Change the log level + +#### via Dart code + +To set the log level filter in the Dart code initialize logging with `FRBLogger.initLogger(maxLoglevel: "WARNING");` (where `newMaxLogLevel` is a mixture of Rust's log levels and [Dart's logging package equivalents](https://pub.dev/documentation/logging/latest/logging/Level-class.html), as described above). +Like anything else, this level will be applied to both, logging statements in Rust and Dart. + +#### via Rust code + +To do the same from your Rust code, you can call `enable_frb_logging!(maxLoglevel: "WARNING");`. +Note that you must use the Dart logging package's log level names as well. + +#### Via an environment variable + +You can set the log level via an environment variable as well. + +Set `LOG_LEVEL=` to a value from the [Dart logging package](https://pub.dev/documentation/logging/latest/logging/Level-class.html). +This will override any programmatically set level. + +### Customize logging output + +Out-of-the-box log messages are sent to _stdout_. If you want to customize the output or replace it with one from a more sophisticated logging framework (e.g. logging to a file), all you need to do is register your custom function for log outputs. + +To do this, set the parameter `customLogFunction`. +This is a `void Function(MirLogRecord)` in Dart and `fn _default_log_fn(record: MirLogRecord)` in Rust. +Instead of a function you can pass a closure as well, in both languages. + +To do so, in your **Dart** code, call +```Dart +FRBLogger.initLogger(customLogFunction: (MirLogRecord record) => {print("This is ${record.level}! ${record.message}")}); +``` +or in your **Rust** code call: +```Rust +enable_frb_logging!( + customLogFunction = (|record: MirLogRecord| { + let lang = if record.rust_log {"Rust"} else {"Dart"}; + let line_number = record.line_number + .map_or("".to_string(), |number| format!(":{}", number)); + format!("[{} {} @{lang} {}{line_number}] {})", record.timestamp, + record.level_name, record.logger_name, record.message) + }) +); ``` +This Rust function is the implemented default. -In other words, use the corresponding platform logger -(https://crates.io/crates/android_logger and https://crates.io/crates/oslog). +Note that your custom log function should be written in the same language where you configure it, i.e. in Dart when using `FRBLogger.initLogger` and in Rust when using `enable_frb_logging!`. -## Example 3: My logger in production +If you specify a custom log function to both calls the Dart function will be used (and the custom function specified in Rust will be ignored).**** -In my own app in production, I use the following strategy for Rust logging: Use normal Rust logging methods, such as `info!` and `debug!` macros. The logs are consumed in two places: They are printed via platform-specific methods (like android Logcat and iOS NSLog), and also use a Stream to send them to the Dart side such that my Dart code and further process are using the same pipeline as normal Dart logs (e.g. save to a file, send to server, etc). +If you are using `FRBLogger.initLogger` (and not `enable_frb_logging!()`) be careful to call this before any `.getLogger()` call! +Otherwise the Rust logger doesn't get initialized correctly. -The *full* code related to logging in my app can be seen here: [#486](https://github.com/fzyzcjy/flutter_rust_bridge/issues/486). +#### utilize a logging framework +The logging support in FRB is intentionally kept low profile, meaning that the logging harness of the language teams (Rust and Dart) are used. +This takes care of dealing with log levels and computing the log message - but not where to write it to. Per default log messages are written to `stdout`. -## Example 4: Send Rust logs to Dart +However, usually this is not enough - you might want to log into a file, a database or another output so you can see log messages from an application inside an emulator or physical device. -@MnlPhlp encapsulates the step-by-step example below into a small Rust package, -such that you can setup Rust-logging-to-Dart in several lines. -Please refer to https://github.com/mnlphlp/flutter_logger for details. +To do so you need to use a logging framework in addition. +Set up the framework as usual and configure its logging function as the custom log function of FRB, as shown above. -## Example 5: A step-by-step guide to send Rust logs to Dart +##### configure the logger package +For example, let's take the Flutter package [logger](https://pub.dev/packages/logger): -Let us implement a simple logging system (adapted from the logging system I use with `flutter_rust_bridge` in my app in production), where Rust code can send logs to Dart code. +1. Add the package to your app, e.g. via `dart pub add logger`. +2. Customize the logging output before any call to `.getLogger`: +```Dart +// import the framework doing the customized output +import 'package:logger/logger.dart'; +// if names are clashing you might have to alias the internally used Logger class. You don't need to add it to your `pubspec.yaml`. +import 'package:logging/logging.dart' as Logging; +// import FRBDartLogger and LogLevel to be used in the customization +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +``` +(...) +```Dart +late final FRBDartLogger logger; +``` +(...) +```Dart + // setup logging + var frameworkLogger = Logger(); + logger = FRBLogger.initLogger( + name: "StateHandler", + maxLogLevel: LogLevel.debug, + customLogFunction: ({required record}) { + final message = + "[${record.timestamp} ${record.levelName} ${record.rustLog ? "Rust: " : "Dart: "} LoggerName: ${record.loggerName}:${record.lineNumber ?? ""}]\n ${record.message}"; + frameworkLogger.log(_toLoggerLevel(record.levelNumber), message); + }, + ); +``` +The framework requires a log level to be set. Our neutral representation `MirLogRecord` provides a number, which should be mapped to the logging framework's level. +We are implementing this helper function for that: +```Dart +// convert MirLogRecord.levelNumber to logger.level + static Level _toLoggerLevel(int levelNumber) { + switch (levelNumber) { + case <= 1000: + return Level.trace; + case <= 2000: + return Level.debug; + case <= 3000: + return Level.info; + case <= 4000: + return Level.warning; + case <= 5000: + return Level.error; + case <= 6000: + return Level.fatal; + default: + return Level.all; + } + } +``` -The Rust `api.rs`: +#### Anatomie of the log output -```rust -pub struct LogEntry { - pub time_millis: i64, - pub level: i32, - pub tag: String, - pub msg: String, -} +The log function in both languages takes a `MirLogRecord` as parameter: -// Simplified just for demonstration. -// To compile, you need a OnceCell, or Mutex, or RwLock -// Also see https://github.com/fzyzcjy/flutter_rust_bridge/issues/398 -lazy_static! { static ref log_stream_sink: StreamSink; } +`MirLogRecord` combines the information from Dart's [LogRecord](https://pub.dev/documentation/logging/latest/logging/LogRecord-class.html) and Rust's [log::Record](https://docs.rs/log/0.4.22/log/struct.Record.html) as follows -pub fn create_log_stream(s: StreamSink) { - stream_sink = s; +```Rust +pub struct MirLogRecord { + pub level_number: u16, // The log level encoded. Decode with `FRBLogger.logLevelFromNumber(x)` in Dart or `from_u16(x)` in Rust. : `Rust::log::Record::Level`, `Dart::Logger::LogRecord::Level` + pub message: String, // The String given to the log statement: `Rust::log::Record::args`, `Dart::Logger::LogRecord::message` + pub logger_name: String, // The name of the logger given by `FRBLogger.initLogger(name: "MyClass");`, `Rust::log::Record::target`, `Dart::Logger::LogRecord::loggerName` + // pub time: String, // log::Record::?, Dart::Logger::LogRecord::time --> omitted, as there is no time record in the log crate's Record + pub rust_log: bool, // true, if the log statement originates from Rust code + pub module_path: Option, // `Rust::log::Record::module_path`, None for Dart + pub file_name: Option, // `Rust::log::Record::file_name`, None for Dart + pub line_number: Option, // `Rust::log::Record::line_number`, None for Dart } ``` -Now Rust will probably complain at you because `IntoDart` is not implemented for `LogEntry`. This is expected, because `flutter_rust_bridge` will generate this trait implementation for you. -To fix this error you should just rerun `flutter_rust_bridge_codegen`. +### Customize the log target +If you want to use log messages produced by another framework and/or send the log messages to other outputs, like a file, you can do this as well by providing a custom log function as described above. -Generated Dart code: +Here you can use any Dart (or Rust) code, it doesn't need to be a closure, but that might be easier. +Your function only needs to take a single argument of type `LogRecord` as input and return nothing. -```Dart -Stream createLogStream(); +Whatever you provide will be called whenever a log statement is called in Rust or Dart. +If you want to combine multiple targets, like `stdout` and a file, combine them in one function. + +## implementation + +In a nutshell, our implementation uses the Rust [log crate](https://crates.io/crates/log) and the Dart [logging package](https://pub.dev/packages/logging), which are maintained by the respective language teams. + +Log messages are sent via a FRB's Stream implementation from Rust to Dart. + +### Log Levels + +While the Dart logging level names are unusual, they are more fine-granular. +The Rust-side [log levels](https://docs.rs/log/0.4.22/log/enum.LevelFilter.html) are mapped to the Dart-side [log levels](https://pub.dev/documentation/logging/latest/logging/Level-class.html) as follows: + +```Rust + match level { + // Level('ALL', 0); + // Level('OFF', 2000); + // Level('FINEST', 300); + // Level('FINER', 400); + // Level('FINE', 500); + 0..=500 => LevelFilter::Trace, + // Level('CONFIG', 700); + 501..=700 => LevelFilter::Debug, + // Level('INFO', 800); + 701..=800 => LevelFilter::Info, + // Level('WARNING', 900); + 801..=900 => LevelFilter::Warn, + // Level('SEVERE', 1000); + // Level('SHOUT', 1200); + 901..2000 => LevelFilter::Error, + // Level('OFF', 2000); + 2000.. => LevelFilter::Off, + } ``` -Now let us use it in Dart: +However, we replaced the more exotic levels on the Dart side with the more common levels from Rust: +- FINE -> trace +- CONFIG -> debug +- SEVERE -> error +- SHOUT -> fatal + +Thus, when logging from Dart, you can use these levels: +```Dart +enum LogLevel { + /// Maps to `Level.ALL` and integer levels below 300. + all( + level: Level.ALL, + levelNumberThreshold: 300, + ), -```dart -Future setup() async { - createLogStream().listen((event) { - print('log from rust: ${event.level} ${event.tag} ${event.msg} ${event.timeMillis}'); - }); + /// Maps to `Level.FINEST` and integer levels below 400. + finest( + level: Level.FINEST, + levelNumberThreshold: 400, + ), + + /// Maps to `Level.FINER` and integer levels below 500. + finer( + level: Level.FINER, + levelNumberThreshold: 500, + ), + + /// Maps to `Level.FINE` and integer levels below 700. This is typically used for Trace. + trace( + level: Level.FINE, + levelNumberThreshold: 700, + ), + + /// Maps to `Level.CONFIG` and integer levels below 800. This is typically used for Debug. + debug( + level: Level.CONFIG, + levelNumberThreshold: 800, + ), + + /// Maps to `Level.INFO` and integer levels below 900. + info( + level: Level.INFO, + levelNumberThreshold: 900, + ), + + /// Maps to `Level.WARNING` and integer levels below 1000. This is typically used for Warn. + warn( + level: Level.WARNING, + levelNumberThreshold: 1000, + ), + + /// Maps to `Level.SEVERE` and integer levels below 1200. This is typically used for Error. + error( + level: Level.SEVERE, + levelNumberThreshold: 1200, + ), + + /// Maps to `Level.SHOUT` and integer levels below 2000. This is typically used for Fatal/Shout. + fatal( + level: Level.SHOUT, + levelNumberThreshold: 2000, + ), + + /// Maps to `Level.OFF` and integer levels equal to or above 2000. + off( + level: Level.OFF, + levelNumberThreshold: 2000, // Or any value that signifies 'Off' + ); } ``` -And now we can happily log anything in Rust: +As you can see you can define additional levels(`Level(String name, int value)`, stay between 0 and 2000) in Dart. +They will convert to Rust seamlessly. + +### Remarks +#### noop function + +`FRBLogger` exposes a `no-op` function, called `newInstance()`. +This is primarily needed so that the code is picked up for code generation, and not optimized away. +However, if called it panics, reminding that a direct instance of `FRBLogger` is not to be created, instead you need to use `FRBLogger.initLogger()` in your Dart code. + + +## Troubleshooting +### Unrecognized literal: `(/*ERROR*/)` +If you get the error message +``` +Running `(...)/target/debug/flutter_rust_bridge_codegen generate` +thread 'main' panicked at (...)/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-2.0.28/src/lit.rs:1095:13: +Unrecognized literal: `(/*ERROR*/)` +``` +the code in the `enable_frb_logging!();` macro has not been expanded correctly - most probably you forgot to add the dependency to `log = "^0.4.20"` in your Cargo.toml file or you passed a syntactically incorrect custom function to the macro. + +### no `__FrbStreamSinkForLogging` in the root +If you get the error message +``` +enable_frb_logging!(); + | ^^^^^^^^^^^^^^^^^^^^^ no `__FrbStreamSinkForLogging` in the root + | + = note: this error originates in the macro `enable_frb_logging` (in Nightly builds, run with -Z macro-backtrace for more info) +``` -```rust -log_stream_sink.add(LogEntry { msg: "hello I am a log from Rust", ... }) +the `StreamSink` is probably not re-exported in your project's `lib.rs`. +Add +``` +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; ``` +to do so. +Notice that `frb_generated` has to point to the module path where you configured the generated code to be written to, which defaults to `crate::frb_generated`. -Of course, you can implement a logger following the Rust's `log` crate wrapping this raw stream sink, then you can use standard Rust logging mechanisms like `info!`. I did exactly that in my project. +### no log output in the emulator! +If you are testing a Flutter application in an emulator the output to `stdout` is not visible. +You need to configure a logging plugin to work with, as described above in `utilize a logging framework`. \ No newline at end of file From 0f9ae8887f648bb9c1f8a375270b7c260d4d7e4a Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 09:46:20 +0200 Subject: [PATCH 04/26] removes oppinionated logging --- frb_codegen/src/binary/commands_parser.rs | 8 - .../config/internal_config_parser/mod.rs | 2 - .../library/codegen/generator/api_dart/mod.rs | 2 - frb_codegen/src/library/codegen/parser/mod.rs | 2 - frb_codegen/src/library/utils/logs.rs | 140 ------------------ frb_codegen/src/library/utils/mod.rs | 1 - frb_codegen/src/main.rs | 5 - frb_example/dart_build_rs/rust/build.rs | 5 - frb_rust/src/misc/user_utils.rs | 25 +--- frb_rust/src/misc/web_utils.rs | 47 +++--- 10 files changed, 31 insertions(+), 206 deletions(-) delete mode 100644 frb_codegen/src/library/utils/logs.rs diff --git a/frb_codegen/src/binary/commands_parser.rs b/frb_codegen/src/binary/commands_parser.rs index 5e2f4bcfdfc..eb96b6e9b46 100644 --- a/frb_codegen/src/binary/commands_parser.rs +++ b/frb_codegen/src/binary/commands_parser.rs @@ -79,7 +79,6 @@ mod tests { use crate::binary::test_utils::set_cwd_test_fixture; use clap::Parser; use itertools::concat; - use lib_flutter_rust_bridge_codegen::utils::logs::configure_opinionated_test_logging; use lib_flutter_rust_bridge_codegen::{codegen, if_then_some}; use serial_test::serial; @@ -88,7 +87,6 @@ mod tests { #[serial] fn test_compute_codegen_config_mode_from_files_auto_flutter_rust_bridge_yaml( ) -> anyhow::Result<()> { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser/flutter_rust_bridge_yaml")?; let config = run_command_line(vec!["", "generate"])?; @@ -101,7 +99,6 @@ mod tests { #[test] #[serial] fn test_compute_codegen_config_mode_from_files_auto_pubspec_yaml() -> anyhow::Result<()> { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser/pubspec_yaml")?; let config = run_command_line(vec!["", "generate"])?; @@ -115,7 +112,6 @@ mod tests { #[serial] fn test_compute_codegen_config_mode_from_files_auto_pubspec_yaml_faulty() -> anyhow::Result<()> { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser/faulty_pubspec_yaml")?; let result = run_command_line(vec!["", "generate"]); @@ -133,7 +129,6 @@ mod tests { #[test] #[serial] fn test_compute_codegen_config_mode_config_file() -> anyhow::Result<()> { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser/config_file")?; let config = run_command_line(vec!["", "generate", "--config-file", "hello.yaml"])?; @@ -146,7 +141,6 @@ mod tests { #[test] #[serial] fn test_compute_codegen_config_mode_config_file_faulty_file() -> anyhow::Result<()> { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser/flutter_rust_bridge_yaml")?; let result = run_command_line(vec![ "", @@ -167,7 +161,6 @@ mod tests { #[test] #[serial] fn test_compute_codegen_config_mode_from_naive_generate_command_args() { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser").unwrap(); // use whatever folder without config file // bool flags @@ -195,7 +188,6 @@ mod tests { #[test] #[serial] fn test_compute_codegen_config_from_both_file_and_command_line() -> anyhow::Result<()> { - configure_opinionated_test_logging(); set_cwd_test_fixture("binary/commands_parser/flutter_rust_bridge_yaml")?; let config = run_command_line(vec!["", "generate", "--llvm-path", "/my/path"])?; diff --git a/frb_codegen/src/library/codegen/config/internal_config_parser/mod.rs b/frb_codegen/src/library/codegen/config/internal_config_parser/mod.rs index 2163dede21b..00384c8111d 100644 --- a/frb_codegen/src/library/codegen/config/internal_config_parser/mod.rs +++ b/frb_codegen/src/library/codegen/config/internal_config_parser/mod.rs @@ -206,7 +206,6 @@ mod tests { use crate::codegen::config::config::MetaConfig; use crate::codegen::config::internal_config::InternalConfig; use crate::codegen::Config; - use crate::utils::logs::configure_opinionated_test_logging; use crate::utils::test_utils::{ create_path_sanitizers, get_test_fixture_dir, json_golden_test, }; @@ -229,7 +228,6 @@ mod tests { } fn body(fixture_name: &str) -> anyhow::Result<()> { - configure_opinionated_test_logging(); let test_fixture_dir = get_test_fixture_dir(fixture_name); env::set_current_dir(&test_fixture_dir)?; info!("test_fixture_dir={test_fixture_dir:?}"); diff --git a/frb_codegen/src/library/codegen/generator/api_dart/mod.rs b/frb_codegen/src/library/codegen/generator/api_dart/mod.rs index 073617becdb..c9e7ec4e2a3 100644 --- a/frb_codegen/src/library/codegen/generator/api_dart/mod.rs +++ b/frb_codegen/src/library/codegen/generator/api_dart/mod.rs @@ -50,7 +50,6 @@ mod tests { use crate::codegen::generator::api_dart::generate; use crate::codegen::misc::GeneratorProgressBarPack; use crate::codegen::Config; - use crate::utils::logs::configure_opinionated_test_logging; use crate::utils::test_utils::{get_test_fixture_dir, text_golden_test}; use serial_test::serial; use std::collections::HashMap; @@ -82,7 +81,6 @@ mod tests { } fn body(fixture_name: &str, expect_outputs: HashMap<&str, &str>) -> anyhow::Result<()> { - configure_opinionated_test_logging(); let test_fixture_dir = get_test_fixture_dir(fixture_name); env::set_current_dir(&test_fixture_dir)?; diff --git a/frb_codegen/src/library/codegen/parser/mod.rs b/frb_codegen/src/library/codegen/parser/mod.rs index 225d0ca854c..76f166719df 100644 --- a/frb_codegen/src/library/codegen/parser/mod.rs +++ b/frb_codegen/src/library/codegen/parser/mod.rs @@ -71,7 +71,6 @@ mod tests { ParserMirInternalConfig, RustInputNamespacePack, }; use crate::codegen::parser::{parse_inner, MirPack}; - use crate::utils::logs::configure_opinionated_test_logging; use crate::utils::namespace::Namespace; use crate::utils::test_utils::{ create_path_sanitizers, get_test_fixture_dir, json_golden_test, @@ -157,7 +156,6 @@ mod tests { fixture_name: &str, rust_input_namespace_pack: Option RustInputNamespacePack>>, ) -> anyhow::Result<(MirPack, PathBuf)> { - configure_opinionated_test_logging(); let test_fixture_dir = get_test_fixture_dir(fixture_name); let rust_crate_dir = test_fixture_dir.clone(); info!("test_fixture_dir={test_fixture_dir:?}"); diff --git a/frb_codegen/src/library/utils/logs.rs b/frb_codegen/src/library/utils/logs.rs deleted file mode 100644 index 647052c60a7..00000000000 --- a/frb_codegen/src/library/utils/logs.rs +++ /dev/null @@ -1,140 +0,0 @@ -//! Utilities related to logging - -use crate::utils::console::MULTI_PROGRESS; -use fern::colors::{Color, ColoredLevelConfig}; -use log::LevelFilter; -use std::io::IsTerminal; - -/// Configure an opinionated way of logging. -/// -/// This is just one way of outputing logs, and users are free to use this function -/// or choose their own way of outputing logs. That's why this function is "opinionated". -/// -/// It will log to file and standard output. -/// All logs with level `debug`(with parameter `verbose`=true or system variable `RUST_LOG`="debug") or above -/// will be recorded in `./logs/.log`. -/// Logs with level `info` and above will be output to standard output, with colored tag. -/// -/// # Example -/// -/// ``` -/// use lib_flutter_rust_bridge_codegen::utils::logs::configure_opinionated_logging; -/// configure_opinionated_logging("./logs/", false).expect("failed to initialize log"); -/// ``` -pub fn configure_opinionated_logging(path: &str, verbose: bool) -> Result<(), fern::InitError> { - let level_filter = log_level_from_env_var().unwrap_or_else(|| verbose_to_level_filter(verbose)); - - if level_filter == LevelFilter::Debug { - std::fs::create_dir_all(path).unwrap(); - } - - let mut fern_logger = fern::Dispatch::new(); - fern_logger = log_format_simple(fern_logger); - fern_logger = match level_filter { - LevelFilter::Debug => fern_logger - .level(LevelFilter::Debug) - .chain(fern::DateBased::new(path, "%Y-%m-%d.log")) - .chain(std::io::stdout()), - LevelFilter::Info => fern_logger - .level(LevelFilter::Info) - .level_for("cbindgen", LevelFilter::Error) - .chain(std::io::stdout()), - _ => fern_logger.level(level_filter).chain(std::io::stdout()), - }; - - let (max_level, fern_logger) = fern_logger.into_log(); - let log_wrapper = indicatif_log_bridge::LogWrapper::new(MULTI_PROGRESS.clone(), fern_logger); - - // ref: fern.apply / LogWrapper.try_init - log::set_boxed_logger(Box::new(log_wrapper))?; - log::set_max_level(max_level); - - let prev = std::panic::take_hook(); - std::panic::set_hook(Box::new(move |info| { - log::error!("{}", info); - prev(info); - })); - - Ok(()) -} - -fn log_level_from_env_var() -> Option { - (std::env::var("RUST_LOG").ok()).map(|value| log_level_from_str(&value)) -} - -fn log_level_from_str(value: &str) -> LevelFilter { - match value { - "trace" => LevelFilter::Trace, - "debug" => LevelFilter::Debug, - "info" => LevelFilter::Info, - "warn" => LevelFilter::Warn, - "error" => LevelFilter::Error, - "off" => LevelFilter::Off, - // frb-coverage:ignore-start - _ => panic!("{}", "unknown RUST_LOG level: {value}"), - // frb-coverage:ignore-end - } -} - -fn verbose_to_level_filter(verbose: bool) -> LevelFilter { - if verbose { - LevelFilter::Debug - } else { - LevelFilter::Info - } -} - -fn log_format_simple(d: fern::Dispatch) -> fern::Dispatch { - let colored_output = ColoredLevelConfig::new() - .error(Color::Red) - .warn(Color::Yellow) - .info(Color::Green) - .debug(Color::Blue) - .trace(Color::BrightBlack); - - d.format(move |out, message, record| { - let time = chrono::Utc::now().format("%Y-%m-%dT%H:%M:%S%.3fZ"); - - let level = record.level(); - let level = if std::io::stdout().is_terminal() { - colored_output.color(level).to_string() - } else { - level.to_string() - }; - - out.finish(format_args!( - "[{} {} {}:{}] {}", - time, - level, - record.file().unwrap_or(""), - record.line().unwrap_or(0), - message - )) - }) -} - -/// Configure an opinionated way of logging, useful in tests. -pub fn configure_opinionated_test_logging() { - // https://github.com/daboross/fern/issues/54 - // This will fail if called twice; don't worry. - let _ = log_format_simple(fern::Dispatch::new()) - .level(log_level_from_env_var().unwrap_or(LevelFilter::Debug)) - .chain(fern::Output::call(|record| println!("{}", record.args()))) - .apply(); -} - -#[cfg(test)] -mod tests { - use crate::utils::logs::log_level_from_str; - use log::LevelFilter; - - #[test] - pub fn test_log_level_from_str() { - assert_eq!(log_level_from_str("trace"), LevelFilter::Trace); - assert_eq!(log_level_from_str("debug"), LevelFilter::Debug); - assert_eq!(log_level_from_str("info"), LevelFilter::Info); - assert_eq!(log_level_from_str("warn"), LevelFilter::Warn); - assert_eq!(log_level_from_str("error"), LevelFilter::Error); - assert_eq!(log_level_from_str("off"), LevelFilter::Off); - } -} diff --git a/frb_codegen/src/library/utils/mod.rs b/frb_codegen/src/library/utils/mod.rs index 0dcdc4ee130..837480a11ea 100644 --- a/frb_codegen/src/library/utils/mod.rs +++ b/frb_codegen/src/library/utils/mod.rs @@ -9,7 +9,6 @@ pub(crate) mod dart_keywords; pub(crate) mod dart_repository; mod enum_map; pub(crate) mod file_utils; -pub mod logs; pub(crate) mod namespace; pub(crate) mod path_utils; pub(crate) mod rust_project_utils; diff --git a/frb_codegen/src/main.rs b/frb_codegen/src/main.rs index c8488a84815..1b18200e2ae 100644 --- a/frb_codegen/src/main.rs +++ b/frb_codegen/src/main.rs @@ -9,14 +9,12 @@ use crate::binary::commands::{Cli, Commands, CreateOrIntegrateCommandCommonArgs} use crate::binary::commands_parser::{compute_codegen_config, compute_codegen_meta_config}; use clap::Parser; use lib_flutter_rust_bridge_codegen::integration::{CreateConfig, IntegrateConfig}; -use lib_flutter_rust_bridge_codegen::utils::logs::configure_opinionated_logging; use lib_flutter_rust_bridge_codegen::*; use log::{debug, warn}; use std::path::Path; fn main() -> anyhow::Result<()> { let cli = Cli::parse(); - configure_opinionated_logging("./logs/", cli.verbose)?; main_given_cli(cli) } @@ -85,9 +83,6 @@ mod tests { // we do not care about coverage of test themselves // frb-coverage:ignore-start fn body_execute_generate(name: &str) -> anyhow::Result<()> { - // if want verbose log, enable it - // configure_opinionated_test_logging(); - if env::var("FRB_SKIP_GENERATE_FRB_EXAMPLE_TEST").unwrap_or_default() == "1" { return Ok(()); } diff --git a/frb_example/dart_build_rs/rust/build.rs b/frb_example/dart_build_rs/rust/build.rs index 150d5f3acf3..87352269c16 100644 --- a/frb_example/dart_build_rs/rust/build.rs +++ b/frb_example/dart_build_rs/rust/build.rs @@ -1,6 +1,5 @@ use lib_flutter_rust_bridge_codegen::codegen; use lib_flutter_rust_bridge_codegen::codegen::Config; -use lib_flutter_rust_bridge_codegen::utils::logs::configure_opinionated_logging; fn main() -> anyhow::Result<()> { // Uncomment the line below, if you only want to generate bindings on api directory change. @@ -11,10 +10,6 @@ fn main() -> anyhow::Result<()> { // // println!("cargo:rerun-if-changed=src/api"); - // If you want to see logs - // Alternatively, use `cargo build -vvv` (instead of `cargo build`) to see logs on screen - configure_opinionated_logging("./logs/", true)?; - // Execute code generator with auto-detected config codegen::generate( Config::from_config_file("../flutter_rust_bridge.yaml")?.unwrap(), diff --git a/frb_rust/src/misc/user_utils.rs b/frb_rust/src/misc/user_utils.rs index f7e654eba32..08522f531fa 100644 --- a/frb_rust/src/misc/user_utils.rs +++ b/frb_rust/src/misc/user_utils.rs @@ -4,8 +4,6 @@ use crate::misc::panic_backtrace::PanicBacktrace; /// Surely, you are free to customize everything. pub fn setup_default_user_utils() { // setup log before others, such that we can see logs in other setup functions - #[cfg(feature = "log")] - setup_log_to_console(); setup_backtrace(); } @@ -21,20 +19,11 @@ fn setup_backtrace() { PanicBacktrace::setup(); } -#[cfg(feature = "log")] -fn setup_log_to_console() { - #[cfg(target_os = "android")] - let _ = android_logger::init_once( - android_logger::Config::default().with_max_level(log::LevelFilter::Trace), - ); +// TODO: check if web logging requires this setup +// #[cfg(feature = "log")] +// fn setup_log_to_console() { +// #[cfg(target_family = "wasm")] +// let _ = crate::misc::web_utils::WebConsoleLogger::init(); - #[cfg(any(target_os = "ios", target_os = "macos"))] - let _ = oslog::OsLogger::new("frb_user") - .level_filter(log::LevelFilter::Trace) - .init(); - - #[cfg(target_family = "wasm")] - let _ = crate::misc::web_utils::WebConsoleLogger::init(); - - // TODO add more platforms -} +// // TODO add more platforms +// } diff --git a/frb_rust/src/misc/web_utils.rs b/frb_rust/src/misc/web_utils.rs index aadecdbf046..a7bf8b094d3 100644 --- a/frb_rust/src/misc/web_utils.rs +++ b/frb_rust/src/misc/web_utils.rs @@ -37,31 +37,32 @@ pub(crate) fn script_path() -> Option { .as_string() } -#[cfg(feature = "log")] -#[derive(Clone, Copy)] -pub(crate) struct WebConsoleLogger; +// TODO check if this is needed for console logging +// #[cfg(feature = "log")] +// #[derive(Clone, Copy)] +// pub(crate) struct WebConsoleLogger; -#[cfg(feature = "log")] -static WEB_CONSOLE_LOGGER: WebConsoleLogger = WebConsoleLogger; +// #[cfg(feature = "log")] +// static WEB_CONSOLE_LOGGER: WebConsoleLogger = WebConsoleLogger; -#[cfg(feature = "log")] -impl WebConsoleLogger { - pub(crate) fn init() -> Result<(), log::SetLoggerError> { - log::set_logger(&WEB_CONSOLE_LOGGER).map(|()| log::set_max_level(log::LevelFilter::Trace)) - } -} +// #[cfg(feature = "log")] +// impl WebConsoleLogger { +// pub(crate) fn init() -> Result<(), log::SetLoggerError> { +// log::set_logger(&WEB_CONSOLE_LOGGER).map(|()| log::set_max_level(log::LevelFilter::Trace)) +// } +// } -#[cfg(feature = "log")] -impl log::Log for WebConsoleLogger { - fn enabled(&self, _metadata: &log::Metadata) -> bool { - true - } +// #[cfg(feature = "log")] +// impl log::Log for WebConsoleLogger { +// fn enabled(&self, _metadata: &log::Metadata) -> bool { +// true +// } - fn log(&self, record: &log::Record) { - if self.enabled(record.metadata()) { - js_console_log(&format!("{} - {}", record.level(), record.args())); - } - } +// fn log(&self, record: &log::Record) { +// if self.enabled(record.metadata()) { +// js_console_log(&format!("{} - {}", record.level(), record.args())); +// } +// } - fn flush(&self) {} -} +// fn flush(&self) {} +// } From ecfaa52cef87564501874682e082706dacea01d6 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:35:25 +0200 Subject: [PATCH 05/26] removes dependencies of old logging --- Cargo.lock | 44 ++------------------------------------------ frb_rust/Cargo.toml | 8 +------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4e14b07ab2..00bac0a2406 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,23 +45,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -533,16 +516,6 @@ dependencies = [ "syn 2.0.85", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -604,7 +577,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "backtrace", "build-target", @@ -620,7 +592,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -1044,9 +1015,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "md-5" @@ -1155,17 +1126,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - [[package]] name = "parking_lot" version = "0.12.1" diff --git a/frb_rust/Cargo.toml b/frb_rust/Cargo.toml index b5a9fdd03cb..8593486c216 100644 --- a/frb_rust/Cargo.toml +++ b/frb_rust/Cargo.toml @@ -47,12 +47,6 @@ web-sys = { version = "0.3.58", features = [ "BroadcastChannel", ] } -[target.'cfg(target_os = "android")'.dependencies] -android_logger = { version = "0.15", optional = true } - -[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies] -oslog = { version = "0.2.0", optional = true } - [build-dependencies] build-target = "0.4.0" @@ -80,7 +74,7 @@ dart-opaque = ["dep:dart-sys"] portable-atomic = ["dep:portable-atomic"] rust-async = ["dep:tokio", "dep:futures", "dep:wasm-bindgen-futures"] thread-pool = ["dep:threadpool"] -user-utils = ["dep:android_logger", "dep:oslog"] +user-utils = [] uuid = ["dep:uuid", "allo-isolate/uuid"] wasm-start = ["console_error_panic_hook"] From a9559fb2224a56a179f27c393b16ec6d16ef235d Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:05:29 +0200 Subject: [PATCH 06/26] removes build file changes for old logging --- .../REPLACE_ME_RUST_CRATE_DIR/Cargo.lock.template | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.lock.template b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.lock.template index 109e064cf8f..a7bd6377595 100644 --- a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.lock.template +++ b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.lock.template @@ -437,17 +437,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8343ce955f18e7e68c0207dd0ea776ec453035685395ababd2ea651c569728b3" -dependencies = [ - "cc", - "dashmap", - "log", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -512,6 +501,7 @@ name = "REPLACE_ME_RUST_CRATE_NAME" version = "0.1.0" dependencies = [ "flutter_rust_bridge", + "log", ] [[package]] @@ -652,4 +642,4 @@ checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", -] +] \ No newline at end of file From 84fb66ea48c567525e8b7b6d124881c8f4f55893 Mon Sep 17 00:00:00 2001 From: patmuk Date: Mon, 23 Jun 2025 10:56:10 +0200 Subject: [PATCH 07/26] fixes build artefacts --- .../codegen/polisher/add_mod_to_lib.rs | 3 +- frb_example/dart_build_rs/rust/Cargo.lock | 40 ---- frb_example/dart_minimal/rust/Cargo.lock | 211 ------------------ frb_example/deliberate_bad/rust/Cargo.lock | 211 ------------------ frb_example/deliberate_bad/rust/src/main.rs | 2 +- frb_example/flutter_package/rust/Cargo.lock | 211 ------------------ .../flutter_via_create/rust/Cargo.lock | 211 ------------------ .../flutter_via_integrate/rust/Cargo.lock | 211 ------------------ frb_example/gallery/rust/Cargo.lock | 191 +--------------- frb_example/gallery/rust/src/frb_generated.rs | 2 +- .../integrate_third_party/rust/Cargo.lock | 207 +---------------- .../rust/src/frb_generated.rs | 2 +- frb_example/pure_dart/rust/Cargo.lock | 143 +----------- .../pure_dart/rust/src/frb_generated.rs | 4 +- frb_example/pure_dart_pde/rust/Cargo.lock | 143 +----------- .../pure_dart_pde/rust/src/frb_generated.rs | 4 +- frb_example/rust_ui_counter/Cargo.lock | 211 ------------------ .../rust_ui_counter/src/frb_generated.rs | 2 +- frb_example/rust_ui_todo_list/Cargo.lock | 211 ------------------ .../rust_ui_todo_list/src/frb_generated.rs | 2 +- frb_rust/src/for_generated/cast.rs | 2 +- .../src/generalized_isolate/web/into_dart.rs | 2 +- frb_rust/src/web_transfer/transfer.rs | 2 +- 23 files changed, 17 insertions(+), 2211 deletions(-) diff --git a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs index bba3745c2df..2e1790d0a94 100644 --- a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs +++ b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs @@ -14,8 +14,7 @@ pub(super) fn try_add_mod_to_lib(rust_crate_dir: &Path, rust_output_path: &Path) warn!( "add_mod_to_lib fail, the generated code may or may not have problems. \ Please ensure you have add code like `mod the_generated_bridge_code;` to your `lib.rs`. \ - Details: {}", - e + Details: {e}" ); // frb-coverage:ignore-end } diff --git a/frb_example/dart_build_rs/rust/Cargo.lock b/frb_example/dart_build_rs/rust/Cargo.lock index b456264f5c2..0afe8955e7f 100644 --- a/frb_example/dart_build_rs/rust/Cargo.lock +++ b/frb_example/dart_build_rs/rust/Cargo.lock @@ -43,23 +43,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -510,16 +493,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -570,7 +543,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -583,7 +555,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -1112,17 +1083,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - [[package]] name = "parking_lot" version = "0.12.1" diff --git a/frb_example/dart_minimal/rust/Cargo.lock b/frb_example/dart_minimal/rust/Cargo.lock index b4a908106d7..fb9a358e1f4 100644 --- a/frb_example/dart_minimal/rust/Cargo.lock +++ b/frb_example/dart_minimal/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -87,12 +61,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -170,19 +138,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -204,22 +159,11 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -232,7 +176,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -364,12 +307,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -403,16 +340,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -469,30 +396,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -529,44 +432,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -579,12 +444,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -594,12 +453,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.48" @@ -728,67 +581,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/deliberate_bad/rust/Cargo.lock b/frb_example/deliberate_bad/rust/Cargo.lock index 421e0aef94d..73500309690 100644 --- a/frb_example/deliberate_bad/rust/Cargo.lock +++ b/frb_example/deliberate_bad/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -90,12 +64,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -173,19 +141,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -207,22 +162,11 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -235,7 +179,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -369,12 +312,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -408,16 +345,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -474,30 +401,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -534,44 +437,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -584,12 +449,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -599,12 +458,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -733,67 +586,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/deliberate_bad/rust/src/main.rs b/frb_example/deliberate_bad/rust/src/main.rs index cfbdeb2fed1..d83c9ab36cb 100644 --- a/frb_example/deliberate_bad/rust/src/main.rs +++ b/frb_example/deliberate_bad/rust/src/main.rs @@ -39,7 +39,7 @@ fn main() { } t1.join().ok(); } - s => panic!("Unknown mode: {}", s), + s => panic!("Unknown mode: {s}"), } } diff --git a/frb_example/flutter_package/rust/Cargo.lock b/frb_example/flutter_package/rust/Cargo.lock index 68dec081402..9ef6b8e1ad5 100644 --- a/frb_example/flutter_package/rust/Cargo.lock +++ b/frb_example/flutter_package/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.27" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -87,12 +61,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -170,19 +138,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -204,16 +159,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_package" version = "0.1.0" @@ -226,7 +171,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -239,7 +183,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -364,12 +307,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -403,16 +340,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -469,30 +396,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -529,56 +432,12 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -588,12 +447,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -718,67 +571,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/flutter_via_create/rust/Cargo.lock b/frb_example/flutter_via_create/rust/Cargo.lock index ec0c63fe845..211acc3d2fb 100644 --- a/frb_example/flutter_via_create/rust/Cargo.lock +++ b/frb_example/flutter_via_create/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.27" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -87,12 +61,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -170,19 +138,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -204,22 +159,11 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -232,7 +176,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -357,12 +300,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -396,16 +333,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -462,30 +389,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -522,44 +425,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rust_lib_flutter_via_create" version = "0.1.0" @@ -573,12 +438,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -588,12 +447,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -718,67 +571,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/flutter_via_integrate/rust/Cargo.lock b/frb_example/flutter_via_integrate/rust/Cargo.lock index 64ccd57f5f3..18166ca5720 100644 --- a/frb_example/flutter_via_integrate/rust/Cargo.lock +++ b/frb_example/flutter_via_integrate/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.27" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -87,12 +61,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -170,19 +138,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -204,22 +159,11 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -232,7 +176,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -357,12 +300,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -396,16 +333,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -462,30 +389,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -522,44 +425,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rust_lib_flutter_via_integrate" version = "0.1.0" @@ -573,12 +438,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -588,12 +447,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -718,67 +571,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/gallery/rust/Cargo.lock b/frb_example/gallery/rust/Cargo.lock index 602a0d47807..92a97c2395d 100644 --- a/frb_example/gallery/rust/Cargo.lock +++ b/frb_example/gallery/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -102,12 +76,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -272,19 +240,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -312,16 +267,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "exr" version = "1.71.0" @@ -371,7 +316,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -384,7 +328,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -528,12 +471,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -753,30 +690,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -795,7 +708,7 @@ version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ - "bitflags 1.3.2", + "bitflags", "crc32fast", "fdeflate", "flate2", @@ -855,44 +768,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags 2.9.1", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rust_lib" version = "0.1.0" @@ -1098,70 +973,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "zune-inflate" version = "0.2.54" diff --git a/frb_example/gallery/rust/src/frb_generated.rs b/frb_example/gallery/rust/src/frb_generated.rs index 12803976e3a..c214b617a58 100644 --- a/frb_example/gallery/rust/src/frb_generated.rs +++ b/frb_example/gallery/rust/src/frb_generated.rs @@ -238,7 +238,7 @@ impl flutter_rust_bridge::IntoIntoDart impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } diff --git a/frb_example/integrate_third_party/rust/Cargo.lock b/frb_example/integrate_third_party/rust/Cargo.lock index 63a1eb78c28..442c170020d 100644 --- a/frb_example/integrate_third_party/rust/Cargo.lock +++ b/frb_example/integrate_third_party/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.86" @@ -105,12 +79,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -250,19 +218,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "dasp_sample" version = "0.11.0" @@ -299,16 +254,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "extend" version = "1.2.0" @@ -337,7 +282,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -350,7 +294,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -475,12 +418,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -537,16 +474,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22edcb39a6fc7e511be7ba578a719af09125391ecde44e0bd61ad3c8e003a4a3" -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -636,30 +563,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "paste" version = "1.0.15" @@ -726,44 +629,6 @@ dependencies = [ "rustfft", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags 2.9.1", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rtrb" version = "0.3.1" @@ -833,12 +698,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -928,7 +787,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "798306779e3dc7d5231bd5691f5a813496dc79d3f56bf82e25789f2094e022c3" dependencies = [ "arrayvec", - "bitflags 1.3.2", + "bitflags", "bytemuck", "lazy_static", "log", @@ -1168,67 +1027,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/integrate_third_party/rust/src/frb_generated.rs b/frb_example/integrate_third_party/rust/src/frb_generated.rs index 660e379911a..d9a7b1b6cf8 100644 --- a/frb_example/integrate_third_party/rust/src/frb_generated.rs +++ b/frb_example/integrate_third_party/rust/src/frb_generated.rs @@ -36135,7 +36135,7 @@ impl flutter_rust_bridge::IntoIntoDart::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } diff --git a/frb_example/pure_dart/rust/Cargo.lock b/frb_example/pure_dart/rust/Cargo.lock index fc74e2f49f9..3a63aba17ae 100644 --- a/frb_example/pure_dart/rust/Cargo.lock +++ b/frb_example/pure_dart/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -45,23 +36,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -216,19 +190,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -250,16 +211,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "errno" version = "0.3.8" @@ -281,7 +232,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "backtrace", "build-target", @@ -296,7 +246,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -448,12 +397,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -522,16 +465,6 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -597,30 +530,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.5.12", - "smallvec", - "windows-targets 0.52.0", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -672,44 +581,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags 2.4.1", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -741,12 +612,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "serde" version = "1.0.193" @@ -787,12 +652,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -812,7 +671,7 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", + "redox_syscall", "rustix", "windows-sys 0.48.0", ] diff --git a/frb_example/pure_dart/rust/src/frb_generated.rs b/frb_example/pure_dart/rust/src/frb_generated.rs index 406f935be30..180146dd0b2 100644 --- a/frb_example/pure_dart/rust/src/frb_generated.rs +++ b/frb_example/pure_dart/rust/src/frb_generated.rs @@ -87246,7 +87246,7 @@ impl impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } @@ -89246,7 +89246,7 @@ impl SseEncode for TypeForIgnoreAll { impl SseEncode for backtrace::Backtrace { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } diff --git a/frb_example/pure_dart_pde/rust/Cargo.lock b/frb_example/pure_dart_pde/rust/Cargo.lock index 8bcdb8d684a..50d6bb245a0 100644 --- a/frb_example/pure_dart_pde/rust/Cargo.lock +++ b/frb_example/pure_dart_pde/rust/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -45,23 +36,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -216,19 +190,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -250,16 +211,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "errno" version = "0.3.8" @@ -281,7 +232,6 @@ name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "backtrace", "build-target", @@ -296,7 +246,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -448,12 +397,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -522,16 +465,6 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -597,30 +530,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.5.12", - "smallvec", - "windows-targets 0.52.0", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -672,44 +581,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags 2.4.1", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -741,12 +612,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "serde" version = "1.0.193" @@ -787,12 +652,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -812,7 +671,7 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", + "redox_syscall", "rustix", "windows-sys 0.48.0", ] diff --git a/frb_example/pure_dart_pde/rust/src/frb_generated.rs b/frb_example/pure_dart_pde/rust/src/frb_generated.rs index 7b046567f63..3358709ad22 100644 --- a/frb_example/pure_dart_pde/rust/src/frb_generated.rs +++ b/frb_example/pure_dart_pde/rust/src/frb_generated.rs @@ -52125,7 +52125,7 @@ impl impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } @@ -53053,7 +53053,7 @@ impl SseEncode for TypeForIgnoreAll { impl SseEncode for backtrace::Backtrace { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } diff --git a/frb_example/rust_ui_counter/Cargo.lock b/frb_example/rust_ui_counter/Cargo.lock index 9d77eb94017..dd34ff3589a 100644 --- a/frb_example/rust_ui_counter/Cargo.lock +++ b/frb_example/rust_ui_counter/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -87,12 +61,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -170,19 +138,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -204,22 +159,11 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -232,7 +176,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -357,12 +300,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -396,16 +333,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -462,30 +389,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -522,44 +425,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rust_lib_frb_example_rust_ui_counter" version = "0.1.0" @@ -579,12 +444,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -594,12 +453,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -728,67 +581,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/rust_ui_counter/src/frb_generated.rs b/frb_example/rust_ui_counter/src/frb_generated.rs index 55943624f80..a06cfbf6d73 100644 --- a/frb_example/rust_ui_counter/src/frb_generated.rs +++ b/frb_example/rust_ui_counter/src/frb_generated.rs @@ -579,7 +579,7 @@ impl flutter_rust_bridge::IntoIntoDart> for RustState { impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } diff --git a/frb_example/rust_ui_todo_list/Cargo.lock b/frb_example/rust_ui_todo_list/Cargo.lock index 8359b177dbe..6d56c26ae15 100644 --- a/frb_example/rust_ui_todo_list/Cargo.lock +++ b/frb_example/rust_ui_todo_list/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allo-isolate" version = "0.1.26" @@ -37,23 +28,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter", - "log", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -87,12 +61,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - [[package]] name = "block-buffer" version = "0.10.4" @@ -170,19 +138,6 @@ dependencies = [ "cc", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "delegate-attr" version = "0.3.0" @@ -204,22 +159,11 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "env_filter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" -dependencies = [ - "log", - "regex", -] - [[package]] name = "flutter_rust_bridge" version = "2.10.0" dependencies = [ "allo-isolate", - "android_logger", "anyhow", "build-target", "bytemuck", @@ -232,7 +176,6 @@ dependencies = [ "js-sys", "lazy_static", "log", - "oslog", "portable-atomic", "threadpool", "tokio", @@ -357,12 +300,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hermit-abi" version = "0.3.3" @@ -396,16 +333,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -462,30 +389,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oslog" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" -dependencies = [ - "cc", - "dashmap", - "log", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -522,44 +425,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rust_lib_frb_example_rust_ui_todo_list" version = "0.1.0" @@ -579,12 +444,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "slab" version = "0.4.9" @@ -594,12 +453,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" - [[package]] name = "syn" version = "2.0.39" @@ -728,67 +581,3 @@ dependencies = [ "js-sys", "wasm-bindgen", ] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/rust_ui_todo_list/src/frb_generated.rs b/frb_example/rust_ui_todo_list/src/frb_generated.rs index 3c97d652da4..0a6f3ac444d 100644 --- a/frb_example/rust_ui_todo_list/src/frb_generated.rs +++ b/frb_example/rust_ui_todo_list/src/frb_generated.rs @@ -911,7 +911,7 @@ impl flutter_rust_bridge::IntoIntoDart for crate::app::Item { impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{:?}", self), serializer); + ::sse_encode(format!("{self:?}"), serializer); } } diff --git a/frb_rust/src/for_generated/cast.rs b/frb_rust/src/for_generated/cast.rs index 0f180c4696f..c37d5cb875c 100644 --- a/frb_rust/src/for_generated/cast.rs +++ b/frb_rust/src/for_generated/cast.rs @@ -8,7 +8,7 @@ pub fn slice_from_byte_buffer(buffer: Vec) -> Box<[T]> { Err(err) => { // clean up before panicking unsafe { core::ptr::drop_in_place(buf) } - panic!("cast error: {}", err); + panic!("cast error: {err}"); } } } diff --git a/frb_rust/src/generalized_isolate/web/into_dart.rs b/frb_rust/src/generalized_isolate/web/into_dart.rs index 0ed1e387c1c..87f9ec9ea4c 100644 --- a/frb_rust/src/generalized_isolate/web/into_dart.rs +++ b/frb_rust/src/generalized_isolate/web/into_dart.rs @@ -349,6 +349,6 @@ impl IntoDart for ZeroCopyBuffer> { #[cfg(feature = "anyhow")] impl IntoDart for anyhow::Error { fn into_dart(self) -> DartAbi { - format!("{:?}", self).into_dart() + format!("{self:?}").into_dart() } } diff --git a/frb_rust/src/web_transfer/transfer.rs b/frb_rust/src/web_transfer/transfer.rs index 7db290c5c41..99a9720b51f 100644 --- a/frb_rust/src/web_transfer/transfer.rs +++ b/frb_rust/src/web_transfer/transfer.rs @@ -33,7 +33,7 @@ impl Transfer for PortLike { } else if value.dyn_ref::().is_some() { value.unchecked_ref::().clone() } else { - panic!("Not a PortLike: {:?}", value) + panic!("Not a PortLike: {value:?}") } } fn serialize(self) -> JsValue { From b6cebe5759376840587108e7d1919c18e1479596 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 09:14:10 +0200 Subject: [PATCH 08/26] adds new files --- frb_dart/lib/src/utils/frb_logger.dart | 300 +++++++++++++ frb_rust/src/misc/logging.rs | 588 +++++++++++++++++++++++++ 2 files changed, 888 insertions(+) create mode 100644 frb_dart/lib/src/utils/frb_logger.dart create mode 100644 frb_rust/src/misc/logging.rs diff --git a/frb_dart/lib/src/utils/frb_logger.dart b/frb_dart/lib/src/utils/frb_logger.dart new file mode 100644 index 00000000000..5313b2db624 --- /dev/null +++ b/frb_dart/lib/src/utils/frb_logger.dart @@ -0,0 +1,300 @@ +// ignore_for_file: avoid_print + +import 'dart:io'; + +import 'package:logging/logging.dart'; + +/// FRB normalized LogLevels +/// Keeps the more fine granular log levels of the logging.dart package while overwriting +/// the unusual ones with the log level names from the rust log crate. +/// +/// This enum also handles the conversion between +/// its own levels and integer numbers to `logging.dart` package's `Level` enum. +enum LogLevel { + /// Maps to `Level.ALL` and integer levels >= 0. + all( + levelNumberThreshold: 0, + ), + + /// Maps to `Level.FINEST` and integer levels >= 300. + finest( + levelNumberThreshold: 300, + ), + + /// Maps to `Level.FINER` and integer levels >= 400. + finer( + levelNumberThreshold: 400, + ), + + /// Maps to `Level.FINE` and integer levels >= 500. This is typically used for Trace. + trace( + levelNumberThreshold: 500, + ), + + /// Maps to `Level.CONFIG` and integer levels >= 700. This is typically used for Debug. + debug( + levelNumberThreshold: 700, + ), + + /// Maps to `Level.INFO` and integer levels >= 800. + info( + levelNumberThreshold: 800, + ), + + /// Maps to `Level.WARNING` and integer levels >= 900. This is typically used for Warn. + warn( + levelNumberThreshold: 900, + ), + + /// Maps to `Level.SEVERE` and integer levels >= 1000. This is typically used for Error. + /// Maps to `Level.SHOUT` and integer levels >= 1200. This is typically used for Fatal/Shout. + error( + levelNumberThreshold: 1999, + ), + + /// Maps to `Level.OFF` and integer levels >= 2000. + off( + levelNumberThreshold: 2000, // Or any value that signifies 'Off' + ); + + /// threshold up to which number mapps to which level + final int levelNumberThreshold; + + const LogLevel({ + required this.levelNumberThreshold, + }); + + /// Converts an integer level number to a [LogLevel] enum. + /// The conversion is based on predefined thresholds and the enum's declaration order. + static LogLevel fromNumber(int levelNumber) { + // The first level whose threshold is greater or equal than the given levelNumber is the correct one. + // This assumes the enum values are declared in ascending order of their thresholds. + for (final level in LogLevel.values) { + if (levelNumber <= level.levelNumberThreshold) { + return level; + } + } + // If no specific level is matched (e.g., if levelNumber is very high but doesn't explicitly hit Off's threshold), + // default to Off. This can happen if the last regular level's threshold is passed. + return LogLevel.off; + } + + /// Maps a string log level name to a `logging.Level`. + /// This is used for parsing initial configuration from strings (e.g., environment variables). + static LogLevel fromString(String levelStr) { + switch (levelStr.toUpperCase()) { + case 'ALL': + return LogLevel.all; + case 'FINEST': + return LogLevel.finest; + case 'FINER': + return LogLevel.finer; + case 'TRACE': + return LogLevel.trace; + case 'DEBUG': + return LogLevel.debug; + case 'INFO': + return LogLevel.info; + case 'WARN': + return LogLevel.warn; + case 'ERROR': + return LogLevel.error; + case 'OFF': + return LogLevel.off; + default: + print( + 'Unknown LOG_LEVEL: "$levelStr". For potential values, refer to LogLevel enum definition.'); + exit(1); // Exit, as this is a critical configuration error + } + } + + /// converts a LogLevel to a logging package's level + Level toLoggingLevel() { + switch (this) { + case LogLevel.all: + return Level.ALL; + case LogLevel.finest: + return Level.FINEST; + case LogLevel.finer: + return Level.FINER; + case LogLevel.trace: + return Level.FINE; + case LogLevel.debug: + return Level.CONFIG; + case LogLevel.info: + return Level.INFO; + case LogLevel.warn: + return Level.WARNING; + case LogLevel.error: + return Level.SHOUT; + case LogLevel.off: + return Level.OFF; + } + } + + /// converts a LogLevel to a logging package's level + static LogLevel fromLoggingLevel(Level level) { + switch (level) { + case Level.ALL: + return LogLevel.all; + case Level.FINEST: + return LogLevel.finest; + case Level.FINER: + return LogLevel.finer; + case Level.FINE: + return LogLevel.trace; + case Level.CONFIG: + return LogLevel.debug; + case Level.INFO: + return LogLevel.info; + case Level.WARNING: + return LogLevel.warn; + case Level.SEVERE: + return LogLevel.error; + case Level.SHOUT: + return LogLevel.error; + case Level.OFF: + return LogLevel.off; + default: + throw Exception("Unknown Dart logging level: $level"); + } + } +} + +/// Call Log functions from the Dart side +/// to be instantiated with FRBLogger.initLogger() +/// NOT initAndGetSingleton directly! +class FRBDartLogger { + /// stream to receive log records from rust code + final Stream streamSink; + + /// default log function + final Function({required MirLogRecord record}) logFn; + + /// function to convert intermediate Log records to Dart LogRecords + final MirLogRecord Function(LogRecord record) fromDartLogRecord; + + // Private constructor to enforce singleton pattern and ensure initialization + const FRBDartLogger._({ + required this.streamSink, + required this.logFn, + required this.fromDartLogRecord, + }); + + // This static field is typed as FRBDartLogger because `frb_logger.dart` cannot + // know the concrete MirLogRecord type from the generated code (in 'frb_rust/misc/logging.rs') at compile time. + static FRBDartLogger? _singleton; + static late String _currentLoggerName; + + /// Initializes the logging system, including the Rust logger. + /// + /// This method is designed to be called **once** from the generated dart file. + /// It takes the concrete `MirLogRecord` type's parameters as `dynamic` arguments, + /// then creates and stores the strongly-typed singleton. + static FRBDartLogger initAndGetSingleton({ + required Stream streamSink, + required void Function({required dynamic record}) logFn, + required MirLogRecordType Function(LogRecord record) fromDartLogRecord, + String name = 'FRBLogger', + LogLevel maxLogLevel = LogLevel.info, + void Function({required dynamic record})? customLogFunction, + }) { + if (_singleton != null) { + throw Exception('Called FRBLogger.initLogger() twice!'); + } + + // Assign the singleton directly using a private constructor. + // The type `dynamic` acts as a placeholder here, but the actual functions + // passed in `streamSink`, `logFn`, `fromDartLogRecord` will be correctly typed + // from the calling side (generated dart code). + _singleton = FRBDartLogger._( + streamSink: streamSink, + logFn: logFn, + fromDartLogRecord: fromDartLogRecord, + ); + + Logger(name); + _currentLoggerName = name; + + String? envLogLevel = Platform.environment['LOG_LEVEL']; + if (envLogLevel != null) { + print( + 'Taking log level from env: $envLogLevel instead of the one given by code: $maxLogLevel'); + maxLogLevel = LogLevel.fromString(envLogLevel); + } + Logger.root.level = maxLogLevel.toLoggingLevel(); + + final Function({required dynamic record}) usedlogFn = + customLogFunction ?? _singleton!.logFn; + + // logs from Rust + _singleton!.streamSink.listen((record) { + usedlogFn(record: record); + }); + + // logs from Dart + Logger.root.onRecord.listen((record) { + usedlogFn(record: _singleton!.fromDartLogRecord(record)); + }); + + return _singleton! as FRBDartLogger; + } + + /// Gets the initialized singleton logger. + /// It returns `FRBDartLogger` as `frb_logger.dart` doesn't know the concrete type. + static FRBDartLogger getLogger([String? name]) { + if (_singleton == null) { + throw Exception("You have to call FRBLogger.initLogger() first!"); + } + var loggerName = name ?? _currentLoggerName; + Logger(loggerName); + _currentLoggerName = loggerName; + return _singleton!; + } + + // These logging methods use the MirLogRecord type from the instance they are called on. + /// finest level logging output + finest(String message) { + Logger(_currentLoggerName).log(LogLevel.finest.toLoggingLevel(), message); + } + + /// finer level logging output + finer(String message) { + Logger(_currentLoggerName).log(LogLevel.finer.toLoggingLevel(), message); + } + + /// trace level logging output + trace(String message) { + Logger(_currentLoggerName).log(LogLevel.trace.toLoggingLevel(), message); + } + + /// debug level logging output + debug(String message) { + Logger(_currentLoggerName).log(LogLevel.debug.toLoggingLevel(), message); + } + + /// info level logging output + info(String message) { + Logger(_currentLoggerName).log(LogLevel.info.toLoggingLevel(), message); + } + + /// warn level logging output + warn(String message) { + Logger(_currentLoggerName).log(LogLevel.warn.toLoggingLevel(), message); + } + + /// error level logging output + error(String message) { + Logger(_currentLoggerName).log(LogLevel.error.toLoggingLevel(), message); + } + + @override + int get hashCode => streamSink.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is FRBDartLogger && + runtimeType == other.runtimeType && + streamSink == other.streamSink; +} diff --git a/frb_rust/src/misc/logging.rs b/frb_rust/src/misc/logging.rs new file mode 100644 index 00000000000..be5a0a2a6f6 --- /dev/null +++ b/frb_rust/src/misc/logging.rs @@ -0,0 +1,588 @@ +#[allow(clippy::crate_in_macro_def)] +#[macro_export] +macro_rules! enable_frb_logging { + () => { + enable_frb_logging!(name = _default_logger_name(), maxLoglevel = _default_max_log_level(), customLogFunction = _default_log_fn); + }; + (name = $RootLoggerName:expr) => { + enable_frb_logging!(name = $RootLoggerName, maxLoglevel = _default_max_log_level(), customLogFunction = _default_log_fn); + }; + (maxLoglevel = $maxLogLevel:expr) => { + enable_frb_logging!(name = _default_logger_name(), maxLoglevel = $maxLogLevel, customLogFunction = _default_log_fn); + }; + (customLogFunction = $log_fn:expr) => { + enable_frb_logging!(name = _default_logger_name(), maxLoglevel = _default_max_log_level(), customLogFunction = $log_fn); + }; + (name = $RootLoggerName:expr, maxLoglevel = $maxLogLevel:expr) => { + enable_frb_logging!(name = $RootLoggerName, maxLoglevel = $maxLogLevel, customLogFunction = _default_log_fn); + }; + (name = $RootLoggerName:expr, customLogFunction = $log_fn:expr) => { + enable_frb_logging!(name = $RootLoggerName, maxLoglevel = _default_log_fn(), customLogFunction = $log_fn); + }; + (maxLoglevel = $maxLogLevel:expr, customLogFunction = $log_fn:expr) => { + enable_frb_logging!(name = _default_logger_name(), maxLoglevel = $maxLogLevel, customLogFunction = $log_fn); + }; + (name = $RootLoggerName:expr, maxLoglevel = $maxLogLevel:expr, customLogFunction = $log_fn:expr) => { + + fn _default_log_fn (record: MirLogRecord) { + println!("{}", _construct_default_message(record)); + } + fn _construct_default_message(record: MirLogRecord) -> String { + let lang = if record.rust_log {"Rust"} else {"Dart"}; + let line_number = record.line_number.map_or("".to_string(), |number| format!(":{}", number)); + format!("[{} {} @{lang} {}{line_number}] {})", record.timestamp, record.level_name.to_uppercase(), record.logger_name, record.message) + } + + fn _default_logger_name () -> String { + "FRBLogger".to_string() + } + fn _default_max_log_level () -> String { + "INFO".to_string() + } + + #[flutter_rust_bridge::frb(sync)] + #[allow(dead_code)] // used by generated dart code + pub fn root_logger_name() -> String { + $RootLoggerName.to_string() + } + #[flutter_rust_bridge::frb(sync)] + #[allow(dead_code)] // used by generated dart code + pub fn max_log_level() -> String { + $maxLogLevel.to_string() + } + + /// this is the call for logging (from Rust and Dart (as logFn)) + #[flutter_rust_bridge::frb(sync)] + #[allow(dead_code)] // used by generated dart code + pub fn log_fn(record: MirLogRecord) { + ($log_fn(record)); + } + + use flutter_rust_bridge::frb; + use crate::__FrbStreamSinkForLogging as StreamSink; + use $crate::for_generated::chrono; + + #[flutter_rust_bridge::frb(dart_code = " + import 'package:logging/logging.dart'; + + static FRBDartLogger initLogger( + {String name = 'FRBLogger', + LogLevel maxLogLevel = LogLevel.info, + Function({required MirLogRecord record}) customLogFunction = logFn}) { + //initialize the rust side + int maxLogLevelNumber = maxLogLevel.levelNumberThreshold; + Stream stream = + initializeLog2Dart(maxLogLevel: maxLogLevelNumber); + + // Functions for type conversion for interaction with frb_dart/utils/frb_logging.dart + // Wrap logFn to match `void Function({required dynamic record})` + void Function({required dynamic record}) wrappedLogFn = + ({required dynamic record}) { + // Safely cast `dynamic` record back to `MirLogRecord` for the original `logFn` + logFn(record: record as MirLogRecord); + }; + // Wrap fromDartLogRecord to match `dynamic Function(LogRecord record)` + MirLogRecord Function(LogRecord record) wrappedFromDartLogRecord = + (LogRecord record) { + return MirLogRecord.fromDartLogRecord(record); + }; + // Wrap customLogFunction if provided, to match `void Function({required dynamic record})?` + void Function({required dynamic record})? wrappedCustomLogFunction; + wrappedCustomLogFunction = ({required dynamic record}) { + customLogFunction(record: record as MirLogRecord); + }; + + return FRBDartLogger.initAndGetSingleton( + streamSink: stream, + name: name, + logFn: wrappedLogFn, + fromDartLogRecord: wrappedFromDartLogRecord, + maxLogLevel: maxLogLevel, + customLogFunction: wrappedCustomLogFunction, + ); + } + + static FRBDartLogger getLogger([String? name]) { + return FRBDartLogger.getLogger(name); + } + ")] + pub struct FRBLogger { + #[allow(clippy::crate_in_macro_def)] + pub stream_sink: StreamSink, + } + + impl FRBLogger { + #[allow(clippy::new_without_default)] + #[allow(dead_code)] // needed for frb_code generation, even though it shouldn't be used! + pub fn new() -> FRBLogger { + panic!("Initialize with `final LOGGER = FRBLogger.getLogger();` or `final LOGGER = FRBLogger.initLogger();`"); + } + } + /// uses custom type translation to translate between log::LogLevel and Dart:logging::Level + /// loglevel is represented by a number, so that we don't need to put \import `import 'package:logging/logging.dart';` + /// into the dart preamble in flutter_rust_bridge.yaml + #[allow(dead_code)] // used by generated dart code + pub fn initialize_log_2_dart(log_stream: StreamSink, max_log_level: u16) { + log::set_boxed_logger(Box::new(FRBLogger { + stream_sink: log_stream, + })) + .map(|()| log::set_max_level(from_u16(max_log_level))) + .expect("initialize_log_2_dart is called only once!"); + + // log panics + let prev = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |info| { + log::error!("{}", info); + prev(info); + })); + } + + impl log::Log for FRBLogger { + fn enabled(&self, metadata: &log::Metadata) -> bool { + metadata.level() <= log::max_level() + } + + fn log(&self, record: &log::Record) { + if self.enabled(record.metadata()) { + self.stream_sink + .add(record.into()) + .expect("could not add to stream while sending to dart "); + } + } + + fn flush(&self) { + //no need to flush the StreamSink + } + } + + fn from_u16(level: u16) -> log::LevelFilter { + match level{ + // Level('ALL', 0); + // Level('OFF', 2000); + // Level('FINEST', 300); + // Level('FINER', 400); + // Level('FINE', 500); + 0..=500 => log::LevelFilter::Trace, + // Level('CONFIG', 700); + 501..=700 => log::LevelFilter::Debug, + // Level('INFO', 800); + 701..=800 => log::LevelFilter::Info, + // Level('WARNING', 900); + 801..=900 => log::LevelFilter::Warn, + // Level('SEVERE', 1000); + // Level('SHOUT', 1200); + 901..2000 => log::LevelFilter::Error, + // Level('OFF', 2000); + 2000.. => log::LevelFilter::Off, + } + } + + fn to_u16(value: log::LevelFilter) -> u16 { + match value { + // ALL → value = 0 + log::LevelFilter::Trace => 0, + // FINEST → value = 300. + // FINER → value = 400. + // FINE → value = 500. + // CONFIG → value = 700. + log::LevelFilter::Debug => 700, + // INFO → value = 800. + log::LevelFilter::Info => 800, + // WARNING → value = 900. + log::LevelFilter::Warn => 900, + // SEVERE → value = 1000. + log::LevelFilter::Error => 1000, + // SHOUT → value = 1200. + // OFF → value = 2000. + log::LevelFilter::Off => 2000, + } + } + + /// custom coders for log::LogLevel <-> Dart:logging::Level + #[frb(rust2dart(dart_type = "Level", dart_code = "LogLevel.fromNumber({}).toLoggingLevel()"))] + #[allow(dead_code)] // used by generated dart code + pub fn encode_log_level_filter(level: log::LevelFilter) -> u16 { + to_u16(level) + } + #[frb(dart2rust(dart_type = "Level", dart_code = "{}.value"))] + #[allow(dead_code)] // used by generated dart code + pub fn decode_log_level_filter(level_number: u16) -> log::LevelFilter { + from_u16(level_number) + } + + /// mapping log crate's [Record](https://docs.rs/log/latest/log/struct.Record.html) to dart's Logger [LogRecord](https://pub.dev/documentation/logging/latest/logging/LogRecord-class.html). + /// intermediary struct to avoid Record's lifetimes + #[derive(Clone)] + #[flutter_rust_bridge::frb(dart_code = " + static MirLogRecord fromDartLogRecord(LogRecord record) { + return MirLogRecord( + message: record.message, + levelNumber: record.level.value, + levelName: LogLevel.fromLoggingLevel(record.level).name.toUpperCase(), + timestamp: record.time.toString(), + loggerName: record.loggerName, + rustLog: false, + ); + } + static LogRecord toDartLogRecordFromMir(MirLogRecord record) { + return LogRecord( + LogLevel.fromString(record.levelName).toLoggingLevel(), + record.message, + record.loggerName, + ); + } + LogRecord toDartLogRecord() { + return toDartLogRecordFromMir(this); + } + ")] + pub struct MirLogRecord { + #[allow(dead_code)] // not used, but there for completeness. A custom log function might want to use this. + pub level_number: u16, // The log level encoded. Decode with `LogLevel.fromNumber(x).toLoggingLevel()` in Dart or `from_u16(x) in Rust. : Rust::log::Recod::Level, Dart::Logger::LogRecord::Level + pub level_name: String, // The log level name in upper case. Rust::log::Recod::Level.level().to_string(), Dart::Logger::LogRecord::Level.name + pub message: String, // The String given to the log statement: Rust::log::Recod::args, Dart::Logger::LogRecord::message + pub logger_name: String, // The name of the logger given by `FRBLogger.initLogger(name: "MyClass");`, Rust::log::Recod::target, Dart::Logger::LogRecord::loggerName + pub timestamp: String, // Dart::Logger::LogRecord::time, Rust: chrono::Local::now(), as there is no time record in the log crate's Record + pub rust_log: bool, // true, if the log statement originates from Rust code + #[allow(dead_code)] // not used, but there for completeness. A custom log function might want to use this. + pub module_path: Option, // Rust::log::Recod::module_path, None for Dart + #[allow(dead_code)] // not used, but there for completeness. A custom log function might want to use this. + pub file_name: Option, // Rust::log::Recod::file_name, None for Dart + #[allow(dead_code)] // not used, but there for completeness. A custom log function might want to use this. + pub line_number: Option, // Rust::log::Recod::line_number, None for Dart + } + + impl From<&log::Record<'_>> for MirLogRecord { + fn from(record: &log::Record) -> Self { + Self { + level_number: to_u16(record.level().to_level_filter()), + level_name: record.level().to_string(), + timestamp: chrono::Local::now().to_string(), + message: record.args().to_string(), + logger_name: record.target().into(), + rust_log: true, + module_path: (record.module_path().or_else(|| record.module_path_static())) + .map(|s| s.into()), + file_name: (record.file().or_else(|| record.file_static())).map(|s| s.into()), + line_number: record.line(), + } + } + } + }; +} + +#[cfg(test)] +pub(crate) mod test { + use flutter_rust_bridge_macros as flutter_rust_bridge; + use log::{Level, Log, Metadata, Record}; + use std::sync::{Arc, Mutex}; + + // A simple mock for StreamSink for testing + #[derive(Debug, Clone)] + pub struct MockStreamSink { + pub sent_records: Arc>>, + } + + impl MockStreamSink { + pub fn new() -> Self { + Self { + sent_records: Arc::new(Mutex::new(Vec::new())), + } + } + + pub fn add(&self, item: T) -> Result<(), crate::Rust2DartSendError> { + self.sent_records.lock().unwrap().push(item); + Ok(()) + } + } + + #[test] + fn test_default_logger_name() { + enable_frb_logging!(); + assert_eq!(_default_logger_name(), "FRBLogger".to_string()); + } + + #[test] + fn test_default_max_log_level() { + enable_frb_logging!(); + assert_eq!(_default_max_log_level(), "INFO".to_string()); + } + + #[test] + fn test_default_log_fn() { + enable_frb_logging!(); + + let record = MirLogRecord { + level_number: to_u16(log::LevelFilter::Debug), + level_name: "debug".to_string(), + timestamp: chrono::Local::now().to_string(), + message: "Test message".to_string(), + logger_name: "TestLogger".to_string(), + rust_log: true, + module_path: Some("test_module".to_string()), + file_name: Some("test_file.rs".to_string()), + line_number: Some(123), + }; + + // println!("{}", _construct_default_message(record.clone())); + assert!( + _construct_default_message(record).contains("DEBUG @Rust TestLogger:123] Test message") + ); + } + + #[test] + #[should_panic( + expected = "Initialize with `final LOGGER = FRBLogger.getLogger();` or `final LOGGER = FRBLogger.initLogger();`" + )] + fn test_frb_logger_new_panics() { + enable_frb_logging!(); + FRBLogger::new(); + } + + #[test] + fn test_initialize_log_2_dart() { + enable_frb_logging!(); + + // Reset the logger and panic hook for a clean test + // This is crucial because `set_boxed_logger` can only be called once. + // In a real application, you might use a `once_cell` or similar to ensure this. + // For testing, we might need to "reset" the global logger state if possible, + // or ensure tests run in isolation (e.g., with `cargo test -- --test-threads=1`). + // For simplicity here, we'll try to catch a potential panic if already set. + let stream_sink = MockStreamSink::new(); + let max_log_level = to_u16(log::LevelFilter::Info); + + let result = std::panic::catch_unwind(|| { + initialize_log_2_dart(stream_sink, max_log_level); + }); + + if result.is_err() { + if let Err(err) = result { + if let Some(msg) = err.downcast_ref::<&str>() { + if msg.contains("initialize_log_2_dart is called only once!") { + // This is expected if another test already initialized it. + // To truly test this, you'd need to ensure test isolation + // or use a different testing approach that doesn't rely on global state. + eprintln!("Warning: initialize_log_2_dart already called in another test. This test might not fully cover the `expect` path."); + } else { + panic!("Unexpected panic: {err:?}"); + } + } else { + panic!("Unexpected panic type: {err:?}"); + } + } + } + } + + #[test] + fn test_frb_logger_enabled() { + enable_frb_logging!(); + let stream_sink = MockStreamSink::new(); + let logger = FRBLogger { stream_sink }; + + // Temporarily set max log level for this test + // NOTE: This modifies global state, which can lead to flaky tests if not carefully managed. + // In a production setup, consider using a logging facade that allows for logger replacement + // or ensure tests run sequentially. + let original_max_level = log::max_level(); + log::set_max_level(log::LevelFilter::Info); + + let metadata_info = Metadata::builder() + .level(Level::Info) + .target("test") + .build(); + let metadata_debug = Metadata::builder() + .level(Level::Debug) + .target("test") + .build(); + let metadata_error = Metadata::builder() + .level(Level::Error) + .target("test") + .build(); + + assert!(logger.enabled(&metadata_info)); + assert!(!logger.enabled(&metadata_debug)); // Debug < Info + assert!(logger.enabled(&metadata_error)); // Error > Info + + log::set_max_level(original_max_level); // Restore original level + } + + #[test] + fn test_frb_logger_log() { + enable_frb_logging!(); + let logger = FRBLogger { + stream_sink: MockStreamSink::new(), + }; + + // Temporarily set max log level for this test + let original_max_level = log::max_level(); + log::set_max_level(log::LevelFilter::Trace); // Enable all for logging + + let record_info = Record::builder() + .level(Level::Info) + .target("test_target") + .args(format_args!("Test message info")) + .module_path(Some("test_module")) + .file(Some("test_file.rs")) + .line(Some(10)) + .build(); + + let record_debug = Record::builder() + .level(Level::Debug) + .target("test_target_debug") + .args(format_args!("Test message debug")) + .build(); + + logger.log(&record_info); + logger.log(&record_debug); + + let sent_records = logger.stream_sink.sent_records.lock().unwrap(); + assert_eq!(sent_records.len(), 2); + + let record1 = &sent_records[0]; + assert_eq!(record1.level_number, to_u16(log::LevelFilter::Info)); + assert_eq!(record1.message, "Test message info"); + assert_eq!(record1.logger_name, "test_target"); + assert!(record1.rust_log); + assert_eq!(record1.module_path, Some("test_module".to_string())); + assert_eq!(record1.file_name, Some("test_file.rs".to_string())); + assert_eq!(record1.line_number, Some(10)); + + let record2 = &sent_records[1]; + assert_eq!(record2.level_number, to_u16(log::LevelFilter::Debug)); + assert_eq!(record2.message, "Test message debug"); + + log::set_max_level(original_max_level); // Restore original level + } + + #[test] + fn test_frb_logger_flush() { + enable_frb_logging!(); + let stream_sink = MockStreamSink::new(); + let logger = FRBLogger { stream_sink }; + // This method does nothing, so we just call it to ensure it doesn't panic. + logger.flush(); + } + + #[test] + fn test_from_u16_trace() { + enable_frb_logging!(); + assert_eq!(from_u16(0), log::LevelFilter::Trace); + assert_eq!(from_u16(300), log::LevelFilter::Trace); + assert_eq!(from_u16(500), log::LevelFilter::Trace); + } + + #[test] + fn test_from_u16_debug() { + enable_frb_logging!(); + assert_eq!(from_u16(501), log::LevelFilter::Debug); + assert_eq!(from_u16(700), log::LevelFilter::Debug); + } + + #[test] + fn test_from_u16_info() { + enable_frb_logging!(); + assert_eq!(from_u16(701), log::LevelFilter::Info); + assert_eq!(from_u16(800), log::LevelFilter::Info); + } + + #[test] + fn test_from_u16_warn() { + enable_frb_logging!(); + assert_eq!(from_u16(801), log::LevelFilter::Warn); + assert_eq!(from_u16(900), log::LevelFilter::Warn); + } + + #[test] + fn test_from_u16_error() { + enable_frb_logging!(); + assert_eq!(from_u16(901), log::LevelFilter::Error); + assert_eq!(from_u16(1500), log::LevelFilter::Error); + assert_eq!(from_u16(1999), log::LevelFilter::Error); + } + + #[test] + fn test_from_u16_off() { + enable_frb_logging!(); + assert_eq!(from_u16(2000), log::LevelFilter::Off); + assert_eq!(from_u16(3000), log::LevelFilter::Off); + } + + #[test] + fn test_to_u16_trace() { + enable_frb_logging!(); + assert_eq!(to_u16(log::LevelFilter::Trace), 0); + } + + #[test] + fn test_to_u16_debug() { + enable_frb_logging!(); + assert_eq!(to_u16(log::LevelFilter::Debug), 700); + } + + #[test] + fn test_to_u16_info() { + enable_frb_logging!(); + assert_eq!(to_u16(log::LevelFilter::Info), 800); + } + + #[test] + fn test_to_u16_warn() { + enable_frb_logging!(); + assert_eq!(to_u16(log::LevelFilter::Warn), 900); + } + + #[test] + fn test_to_u16_error() { + enable_frb_logging!(); + assert_eq!(to_u16(log::LevelFilter::Error), 1000); + } + + #[test] + fn test_to_u16_off() { + enable_frb_logging!(); + assert_eq!(to_u16(log::LevelFilter::Off), 2000); + } + + #[test] + fn test_mir_log_record_from_log_record() { + enable_frb_logging!(); + let log_record = Record::builder() + .level(Level::Info) + .target("my_target") + .args(format_args!("Hello, world!")) + .module_path(Some("my_module")) + .file(Some("my_file.rs")) + .line(Some(42)) + .build(); + + let frb_record: MirLogRecord = (&log_record).into(); + + assert_eq!(frb_record.level_number, to_u16(log::LevelFilter::Info)); + assert_eq!(frb_record.message, "Hello, world!"); + assert_eq!(frb_record.logger_name, "my_target"); + assert!(frb_record.rust_log); + assert_eq!(frb_record.module_path, Some("my_module".to_string())); + assert_eq!(frb_record.file_name, Some("my_file.rs".to_string())); + assert_eq!(frb_record.line_number, Some(42)); + } + + #[test] + fn test_mir_log_record_from_log_record_no_optional_fields() { + enable_frb_logging!(); + let log_record = Record::builder() + .level(Level::Warn) + .target("another_target") + .args(format_args!("Simple message")) + .build(); + + let frb_record: MirLogRecord = (&log_record).into(); + + assert_eq!(frb_record.level_number, to_u16(log::LevelFilter::Warn)); + assert_eq!(frb_record.message, "Simple message"); + assert_eq!(frb_record.logger_name, "another_target"); + assert!(frb_record.rust_log); + assert_eq!(frb_record.module_path, None); + assert_eq!(frb_record.file_name, None); + assert_eq!(frb_record.line_number, None); + } +} From faa62e346a1eb8ff5a0848ab84f26420e24b5eb6 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:17:51 +0200 Subject: [PATCH 09/26] includes new files --- frb_dart/lib/flutter_rust_bridge_for_generated_common.dart | 1 + frb_rust/src/misc/mod.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/frb_dart/lib/flutter_rust_bridge_for_generated_common.dart b/frb_dart/lib/flutter_rust_bridge_for_generated_common.dart index a335de74256..8f365e7c5c9 100644 --- a/frb_dart/lib/flutter_rust_bridge_for_generated_common.dart +++ b/frb_dart/lib/flutter_rust_bridge_for_generated_common.dart @@ -29,3 +29,4 @@ export 'src/misc/simple_disposable.dart'; export 'src/rust_arc/_common.dart'; export 'src/stream/stream_sink.dart'; export 'src/task.dart'; +export 'src/utils/frb_logger.dart'; diff --git a/frb_rust/src/misc/mod.rs b/frb_rust/src/misc/mod.rs index f5390d17ec7..e416fa53eb6 100644 --- a/frb_rust/src/misc/mod.rs +++ b/frb_rust/src/misc/mod.rs @@ -1,6 +1,8 @@ pub(crate) mod atomic; pub(crate) mod dart_dynamic; pub(crate) mod into_into_dart; +#[cfg(feature = "log")] +pub(crate) mod logging; pub(crate) mod logs; pub(crate) mod manual_impl; pub(crate) mod panic_backtrace; From fe7148f0774912a9426010d2967e1600e3d202d3 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:26:22 +0200 Subject: [PATCH 10/26] adds dependencies for new logging --- frb_dart/pubspec.yaml | 1 + frb_example/dart_build_rs/pubspec.lock | 4 +- frb_example/dart_minimal/pubspec.lock | 92 ++++++++++--------- .../flutter_package/example/pubspec.lock | 8 ++ frb_example/flutter_package/rust/Cargo.toml | 2 + frb_example/flutter_package/rust/src/lib.rs | 8 +- frb_example/flutter_via_create/pubspec.lock | 8 ++ .../flutter_via_create/rust/Cargo.toml | 2 + .../flutter_via_create/rust/src/lib.rs | 8 +- .../flutter_via_integrate/pubspec.lock | 8 ++ .../flutter_via_integrate/rust/Cargo.toml | 2 + .../flutter_via_integrate/rust/src/lib.rs | 8 +- .../integrate_third_party/pubspec.lock | 4 +- .../rust/src/frb_generated.rs | 2 +- .../pure_dart/rust/src/frb_generated.rs | 4 +- .../pure_dart_pde/rust/src/frb_generated.rs | 4 +- .../rust_ui_counter/src/frb_generated.rs | 2 +- frb_example/rust_ui_counter/ui/pubspec.lock | 8 ++ .../rust_ui_todo_list/src/frb_generated.rs | 2 +- frb_example/rust_ui_todo_list/ui/pubspec.lock | 8 ++ frb_rust/Cargo.toml | 14 ++- frb_rust/src/for_generated/mod.rs | 2 + tools/frb_internal/pubspec.lock | 4 +- 23 files changed, 144 insertions(+), 61 deletions(-) diff --git a/frb_dart/pubspec.yaml b/frb_dart/pubspec.yaml index 7bb8811e9a1..2a6e2eee51a 100644 --- a/frb_dart/pubspec.yaml +++ b/frb_dart/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: meta: ^1.3.0 path: ^1.8.1 web: '>=0.5.0 <2.0.0' + logging: ^1.3.0 dev_dependencies: # Temporarily remove before https://github.com/kevmoo/build_cli/issues/168 is fixed # build_cli: ^2.2.4 diff --git a/frb_example/dart_build_rs/pubspec.lock b/frb_example/dart_build_rs/pubspec.lock index 53c71c83f9e..49c640924ea 100644 --- a/frb_example/dart_build_rs/pubspec.lock +++ b/frb_example/dart_build_rs/pubspec.lock @@ -352,10 +352,10 @@ packages: dependency: transitive description: name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" macros: dependency: transitive description: diff --git a/frb_example/dart_minimal/pubspec.lock b/frb_example/dart_minimal/pubspec.lock index 3474e400f3a..f68d7c404a9 100644 --- a/frb_example/dart_minimal/pubspec.lock +++ b/frb_example/dart_minimal/pubspec.lock @@ -26,26 +26,26 @@ packages: dependency: transitive description: name: archive - sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd" url: "https://pub.dev" source: hosted - version: "3.6.1" + version: "4.0.7" args: dependency: transitive description: name: args - sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 url: "https://pub.dev" source: hosted - version: "2.6.0" + version: "2.7.0" async: dependency: transitive description: name: async - sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" url: "https://pub.dev" source: hosted - version: "2.12.0" + version: "2.13.0" boolean_selector: dependency: transitive description: @@ -82,26 +82,26 @@ packages: dependency: transitive description: name: build_daemon - sha256: "294a2edaf4814a378725bfe6358210196f5ea37af89ecd81bfa32960113d4948" + sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "4.0.4" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "99d3980049739a985cf9b21f30881f46db3ebc62c5b8d5e60e27440876b1ba1e" + sha256: b9e4fda21d846e192628e7a4f6deda6888c36b5b69ba02ff291a01fd529140f0 url: "https://pub.dev" source: hosted - version: "2.4.3" + version: "2.4.4" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "74691599a5bc750dc96a6b4bfd48f7d9d66453eab04c7f4063134800d6a5c573" + sha256: "058fe9dce1de7d69c4b84fada934df3e0153dd000758c4d65964d0166779aa99" url: "https://pub.dev" source: hosted - version: "2.4.14" + version: "2.4.15" build_runner_core: dependency: transitive description: @@ -122,10 +122,10 @@ packages: dependency: transitive description: name: built_value - sha256: "28a712df2576b63c6c005c465989a348604960c0958d28be5303ba9baa841ac2" + sha256: "082001b5c3dc495d4a42f1d5789990505df20d8547d42507c29050af6933ee27" url: "https://pub.dev" source: hosted - version: "8.9.3" + version: "8.10.1" checked_yaml: dependency: transitive description: @@ -194,10 +194,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" + sha256: "7306ab8a2359a48d22310ad823521d723acfed60ee1f7e37388e8986853b6820" url: "https://pub.dev" source: hosted - version: "2.3.7" + version: "2.3.8" ffi: dependency: transitive description: @@ -272,10 +272,10 @@ packages: dependency: transitive description: name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" graphs: dependency: transitive description: @@ -288,10 +288,10 @@ packages: dependency: transitive description: name: http - sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b" url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.4.0" http_multi_server: dependency: transitive description: @@ -368,18 +368,18 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" meta: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" mime: dependency: transitive description: @@ -408,10 +408,10 @@ packages: dependency: transitive description: name: package_config - sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67" + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.2.0" path: dependency: transitive description: @@ -436,14 +436,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + posix: + dependency: transitive + description: + name: posix + sha256: f0d7856b6ca1887cfa6d1d394056a296ae33489db914e365e2044fdada449e62 + url: "https://pub.dev" + source: hosted + version: "6.0.2" pub_semver: dependency: transitive description: name: pub_semver - sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.2.0" pubspec_parse: dependency: transitive description: @@ -456,10 +464,10 @@ packages: dependency: transitive description: name: puppeteer - sha256: "7a990c68d33882b642214c351f66492d9a738afa4226a098ab70642357337fa2" + sha256: ac8cf90a3202b4658b7a7ba6fb17f1e255905773cd0741108334a93c034ffe76 url: "https://pub.dev" source: hosted - version: "3.16.0" + version: "3.18.0" quiver: dependency: transitive description: @@ -592,26 +600,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" + sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb" url: "https://pub.dev" source: hosted - version: "1.25.15" + version: "1.26.2" test_api: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.6" test_core: dependency: transitive description: name: test_core - sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" + sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a" url: "https://pub.dev" source: hosted - version: "0.6.8" + version: "0.6.11" timing: dependency: transitive description: @@ -632,26 +640,26 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "15.0.2" watcher: dependency: transitive description: name: watcher - sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104" + sha256: "0b7fd4a0bbc4b92641dbf20adfd7e3fd1398fe17102d94b674234563e110088a" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" web: dependency: transitive description: name: web - sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" web_socket_channel: dependency: transitive description: diff --git a/frb_example/flutter_package/example/pubspec.lock b/frb_example/flutter_package/example/pubspec.lock index 8b80ffdce18..7a97fb67024 100644 --- a/frb_example/flutter_package/example/pubspec.lock +++ b/frb_example/flutter_package/example/pubspec.lock @@ -160,6 +160,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: diff --git a/frb_example/flutter_package/rust/Cargo.toml b/frb_example/flutter_package/rust/Cargo.toml index bb992aab412..ce36a49d243 100644 --- a/frb_example/flutter_package/rust/Cargo.toml +++ b/frb_example/flutter_package/rust/Cargo.toml @@ -8,6 +8,8 @@ crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = { path = "../../../frb_rust" } +# Optional - can be removed if you do not want logging +log = "^0.4.20" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] } diff --git a/frb_example/flutter_package/rust/src/lib.rs b/frb_example/flutter_package/rust/src/lib.rs index cbb071f8bf2..a57332801d0 100644 --- a/frb_example/flutter_package/rust/src/lib.rs +++ b/frb_example/flutter_package/rust/src/lib.rs @@ -1,2 +1,8 @@ -pub mod api; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod api; diff --git a/frb_example/flutter_via_create/pubspec.lock b/frb_example/flutter_via_create/pubspec.lock index f2e8b943883..e2ef11737f5 100644 --- a/frb_example/flutter_via_create/pubspec.lock +++ b/frb_example/flutter_via_create/pubspec.lock @@ -153,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: diff --git a/frb_example/flutter_via_create/rust/Cargo.toml b/frb_example/flutter_via_create/rust/Cargo.toml index 80548a59f88..f69b266bbff 100644 --- a/frb_example/flutter_via_create/rust/Cargo.toml +++ b/frb_example/flutter_via_create/rust/Cargo.toml @@ -8,6 +8,8 @@ crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = { path = "../../../frb_rust" } +# Optional - can be removed if you do not want logging +log = "^0.4.20" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] } diff --git a/frb_example/flutter_via_create/rust/src/lib.rs b/frb_example/flutter_via_create/rust/src/lib.rs index cbb071f8bf2..a57332801d0 100644 --- a/frb_example/flutter_via_create/rust/src/lib.rs +++ b/frb_example/flutter_via_create/rust/src/lib.rs @@ -1,2 +1,8 @@ -pub mod api; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod api; diff --git a/frb_example/flutter_via_integrate/pubspec.lock b/frb_example/flutter_via_integrate/pubspec.lock index bad3bc5ad0c..96fb8347624 100644 --- a/frb_example/flutter_via_integrate/pubspec.lock +++ b/frb_example/flutter_via_integrate/pubspec.lock @@ -153,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: diff --git a/frb_example/flutter_via_integrate/rust/Cargo.toml b/frb_example/flutter_via_integrate/rust/Cargo.toml index c04910591b5..b3baa86253f 100644 --- a/frb_example/flutter_via_integrate/rust/Cargo.toml +++ b/frb_example/flutter_via_integrate/rust/Cargo.toml @@ -8,6 +8,8 @@ crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = { path = "../../../frb_rust" } +# Optional - can be removed if you do not want logging +log = "^0.4.20" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] } diff --git a/frb_example/flutter_via_integrate/rust/src/lib.rs b/frb_example/flutter_via_integrate/rust/src/lib.rs index cbb071f8bf2..a57332801d0 100644 --- a/frb_example/flutter_via_integrate/rust/src/lib.rs +++ b/frb_example/flutter_via_integrate/rust/src/lib.rs @@ -1,2 +1,8 @@ -pub mod api; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod api; diff --git a/frb_example/integrate_third_party/pubspec.lock b/frb_example/integrate_third_party/pubspec.lock index c1b9e8f6503..a387e80e1e0 100644 --- a/frb_example/integrate_third_party/pubspec.lock +++ b/frb_example/integrate_third_party/pubspec.lock @@ -378,10 +378,10 @@ packages: dependency: transitive description: name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" macros: dependency: transitive description: diff --git a/frb_example/integrate_third_party/rust/src/frb_generated.rs b/frb_example/integrate_third_party/rust/src/frb_generated.rs index d9a7b1b6cf8..660e379911a 100644 --- a/frb_example/integrate_third_party/rust/src/frb_generated.rs +++ b/frb_example/integrate_third_party/rust/src/frb_generated.rs @@ -36135,7 +36135,7 @@ impl flutter_rust_bridge::IntoIntoDart::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } diff --git a/frb_example/pure_dart/rust/src/frb_generated.rs b/frb_example/pure_dart/rust/src/frb_generated.rs index 180146dd0b2..406f935be30 100644 --- a/frb_example/pure_dart/rust/src/frb_generated.rs +++ b/frb_example/pure_dart/rust/src/frb_generated.rs @@ -87246,7 +87246,7 @@ impl impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } @@ -89246,7 +89246,7 @@ impl SseEncode for TypeForIgnoreAll { impl SseEncode for backtrace::Backtrace { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } diff --git a/frb_example/pure_dart_pde/rust/src/frb_generated.rs b/frb_example/pure_dart_pde/rust/src/frb_generated.rs index 3358709ad22..7b046567f63 100644 --- a/frb_example/pure_dart_pde/rust/src/frb_generated.rs +++ b/frb_example/pure_dart_pde/rust/src/frb_generated.rs @@ -52125,7 +52125,7 @@ impl impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } @@ -53053,7 +53053,7 @@ impl SseEncode for TypeForIgnoreAll { impl SseEncode for backtrace::Backtrace { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } diff --git a/frb_example/rust_ui_counter/src/frb_generated.rs b/frb_example/rust_ui_counter/src/frb_generated.rs index a06cfbf6d73..55943624f80 100644 --- a/frb_example/rust_ui_counter/src/frb_generated.rs +++ b/frb_example/rust_ui_counter/src/frb_generated.rs @@ -579,7 +579,7 @@ impl flutter_rust_bridge::IntoIntoDart> for RustState { impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } diff --git a/frb_example/rust_ui_counter/ui/pubspec.lock b/frb_example/rust_ui_counter/ui/pubspec.lock index 396feeb680c..23e75e34880 100644 --- a/frb_example/rust_ui_counter/ui/pubspec.lock +++ b/frb_example/rust_ui_counter/ui/pubspec.lock @@ -161,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: diff --git a/frb_example/rust_ui_todo_list/src/frb_generated.rs b/frb_example/rust_ui_todo_list/src/frb_generated.rs index 0a6f3ac444d..3c97d652da4 100644 --- a/frb_example/rust_ui_todo_list/src/frb_generated.rs +++ b/frb_example/rust_ui_todo_list/src/frb_generated.rs @@ -911,7 +911,7 @@ impl flutter_rust_bridge::IntoIntoDart for crate::app::Item { impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } diff --git a/frb_example/rust_ui_todo_list/ui/pubspec.lock b/frb_example/rust_ui_todo_list/ui/pubspec.lock index 01ecf618426..72377adedec 100644 --- a/frb_example/rust_ui_todo_list/ui/pubspec.lock +++ b/frb_example/rust_ui_todo_list/ui/pubspec.lock @@ -161,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: diff --git a/frb_rust/Cargo.toml b/frb_rust/Cargo.toml index 8593486c216..45b3b3e2fd9 100644 --- a/frb_rust/Cargo.toml +++ b/frb_rust/Cargo.toml @@ -18,15 +18,22 @@ delegate-attr = "0.3.0" flutter_rust_bridge_macros = { workspace = true } futures = { version = "0.3.29", optional = true } lazy_static = { workspace = true } -log = { version = "0.4", optional = true } +log = { version = "0.4.20", optional = true, features = ["std"] } portable-atomic = { version = "1.8.0", optional = true } uuid = { workspace = true, optional = true } [target.'cfg(not(target_family = "wasm"))'.dependencies] -allo-isolate = { workspace = true, features = ["anyhow", "backtrace", "zero-copy"] } +allo-isolate = { workspace = true, features = [ + "anyhow", + "backtrace", + "zero-copy", +] } dart-sys = { version = "4.1.5", optional = true } threadpool = { version = "1.8.1", optional = true } -tokio = { version = "1.34.0", optional = true, features = ["rt-multi-thread", "sync"] } +tokio = { version = "1.34.0", optional = true, features = [ + "rt-multi-thread", + "sync", +] } [target.'cfg(target_family = "wasm")'.dependencies] bytemuck = "1.11.0" @@ -69,6 +76,7 @@ default = [ "wasm-start", ] backtrace = ["dep:backtrace", "allo-isolate/backtrace"] +log = ["dep:log", "dep:chrono"] chrono = ["dep:chrono", "allo-isolate/chrono"] dart-opaque = ["dep:dart-sys"] portable-atomic = ["dep:portable-atomic"] diff --git a/frb_rust/src/for_generated/mod.rs b/frb_rust/src/for_generated/mod.rs index 83d48562338..d7c45a06583 100644 --- a/frb_rust/src/for_generated/mod.rs +++ b/frb_rust/src/for_generated/mod.rs @@ -70,6 +70,8 @@ pub use anyhow; pub use byteorder; #[cfg(target_family = "wasm")] pub use cast::slice_from_byte_buffer; +#[cfg(feature = "log")] +pub use chrono; #[cfg(feature = "rust-async")] pub use futures; #[cfg(target_family = "wasm")] diff --git a/tools/frb_internal/pubspec.lock b/tools/frb_internal/pubspec.lock index 4621c2f5583..06b06e7ebf0 100644 --- a/tools/frb_internal/pubspec.lock +++ b/tools/frb_internal/pubspec.lock @@ -313,10 +313,10 @@ packages: dependency: transitive description: name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" macros: dependency: transitive description: From 01680ad8f5378e4379281c34d5f8cdb7c2881b71 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:05:42 +0200 Subject: [PATCH 11/26] adds build file changes for new logging --- .../Cargo.toml.template | 2 + .../REPLACE_ME_RUST_CRATE_DIR/src/lib.rs | 8 +- frb_example/dart_build_rs/rust/Cargo.lock | 1 + frb_example/dart_minimal/rust/Cargo.lock | 128 +++++++++++++++++ frb_example/deliberate_bad/rust/Cargo.lock | 128 +++++++++++++++++ frb_example/flutter_package/rust/Cargo.lock | 129 ++++++++++++++++++ .../flutter_via_create/rust/Cargo.lock | 129 ++++++++++++++++++ .../flutter_via_integrate/rust/Cargo.lock | 129 ++++++++++++++++++ frb_example/gallery/rust/Cargo.lock | 119 ++++++++++++++++ .../integrate_third_party/rust/Cargo.lock | 119 ++++++++++++++++ frb_example/rust_ui_counter/Cargo.lock | 128 +++++++++++++++++ frb_example/rust_ui_todo_list/Cargo.lock | 128 +++++++++++++++++ 12 files changed, 1147 insertions(+), 1 deletion(-) diff --git a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.toml.template b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.toml.template index d40635ceced..775be4704cd 100644 --- a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.toml.template +++ b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/Cargo.toml.template @@ -8,6 +8,8 @@ crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = REPLACE_ME_RUST_FRB_DEPENDENCY +# Optional - can be removed if you do not want logging +log = "^0.4.20" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] } diff --git a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs index cbb071f8bf2..a57332801d0 100644 --- a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs +++ b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs @@ -1,2 +1,8 @@ -pub mod api; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod api; diff --git a/frb_example/dart_build_rs/rust/Cargo.lock b/frb_example/dart_build_rs/rust/Cargo.lock index 0afe8955e7f..2613d435a12 100644 --- a/frb_example/dart_build_rs/rust/Cargo.lock +++ b/frb_example/dart_build_rs/rust/Cargo.lock @@ -547,6 +547,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", diff --git a/frb_example/dart_minimal/rust/Cargo.lock b/frb_example/dart_minimal/rust/Cargo.lock index fb9a358e1f4..6d4671fd83d 100644 --- a/frb_example/dart_minimal/rust/Cargo.lock +++ b/frb_example/dart_minimal/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -109,6 +124,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -119,6 +148,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -168,6 +203,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -319,6 +355,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -371,6 +431,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -581,3 +650,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/deliberate_bad/rust/Cargo.lock b/frb_example/deliberate_bad/rust/Cargo.lock index 73500309690..f7a6a334f2b 100644 --- a/frb_example/deliberate_bad/rust/Cargo.lock +++ b/frb_example/deliberate_bad/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -112,6 +127,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -122,6 +151,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -171,6 +206,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -324,6 +360,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -376,6 +436,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -586,3 +655,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/flutter_package/rust/Cargo.lock b/frb_example/flutter_package/rust/Cargo.lock index 9ef6b8e1ad5..d4ee9317e69 100644 --- a/frb_example/flutter_package/rust/Cargo.lock +++ b/frb_example/flutter_package/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -109,6 +124,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -119,6 +148,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -164,6 +199,7 @@ name = "flutter_package" version = "0.1.0" dependencies = [ "flutter_rust_bridge", + "log", ] [[package]] @@ -175,6 +211,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -319,6 +356,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -371,6 +432,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -571,3 +641,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/flutter_via_create/rust/Cargo.lock b/frb_example/flutter_via_create/rust/Cargo.lock index 211acc3d2fb..8ae0daa346f 100644 --- a/frb_example/flutter_via_create/rust/Cargo.lock +++ b/frb_example/flutter_via_create/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -109,6 +124,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -119,6 +148,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -168,6 +203,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -312,6 +348,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -364,6 +424,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -430,6 +499,7 @@ name = "rust_lib_flutter_via_create" version = "0.1.0" dependencies = [ "flutter_rust_bridge", + "log", ] [[package]] @@ -571,3 +641,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/flutter_via_integrate/rust/Cargo.lock b/frb_example/flutter_via_integrate/rust/Cargo.lock index 18166ca5720..97f65447d88 100644 --- a/frb_example/flutter_via_integrate/rust/Cargo.lock +++ b/frb_example/flutter_via_integrate/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -109,6 +124,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -119,6 +148,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -168,6 +203,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -312,6 +348,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -364,6 +424,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -430,6 +499,7 @@ name = "rust_lib_flutter_via_integrate" version = "0.1.0" dependencies = [ "flutter_rust_bridge", + "log", ] [[package]] @@ -571,3 +641,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/gallery/rust/Cargo.lock b/frb_example/gallery/rust/Cargo.lock index 92a97c2395d..2085179893b 100644 --- a/frb_example/gallery/rust/Cargo.lock +++ b/frb_example/gallery/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -124,6 +139,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -140,6 +169,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crc32fast" version = "1.3.2" @@ -320,6 +355,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -483,6 +519,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "image" version = "0.24.7" @@ -973,6 +1033,65 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + [[package]] name = "zune-inflate" version = "0.2.54" diff --git a/frb_example/integrate_third_party/rust/Cargo.lock b/frb_example/integrate_third_party/rust/Cargo.lock index 442c170020d..60c91e7b93d 100644 --- a/frb_example/integrate_third_party/rust/Cargo.lock +++ b/frb_example/integrate_third_party/rust/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.86" @@ -133,6 +148,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -143,6 +172,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "creek" version = "1.2.2" @@ -286,6 +321,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -447,6 +483,30 @@ dependencies = [ "rustfft", ] +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -1027,3 +1087,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/rust_ui_counter/Cargo.lock b/frb_example/rust_ui_counter/Cargo.lock index dd34ff3589a..75bc770d821 100644 --- a/frb_example/rust_ui_counter/Cargo.lock +++ b/frb_example/rust_ui_counter/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -109,6 +124,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -119,6 +148,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -168,6 +203,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -312,6 +348,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -364,6 +424,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -581,3 +650,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/rust_ui_todo_list/Cargo.lock b/frb_example/rust_ui_todo_list/Cargo.lock index 6d56c26ae15..0bad6ca06da 100644 --- a/frb_example/rust_ui_todo_list/Cargo.lock +++ b/frb_example/rust_ui_todo_list/Cargo.lock @@ -28,6 +28,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -109,6 +124,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -119,6 +148,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crypto-common" version = "0.1.6" @@ -168,6 +203,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys", "delegate-attr", @@ -312,6 +348,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -364,6 +424,15 @@ dependencies = [ "adler", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -581,3 +650,62 @@ dependencies = [ "js-sys", "wasm-bindgen", ] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] From d46bf219ae2b73f7a51fb3bd7b1723bc59a34fbe Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:41:32 +0200 Subject: [PATCH 12/26] adds test dependencies --- CHANGELOG.md | 1 + frb_rust/src/lib.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f56f01948..fb710c26d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/guides/miscellaneous/whats-new for what's changed in V2. * Overhaul of the logging implementation, from an opinionated approach to a configurable one. Please consult the [documentation](https://fzyzcjy.github.io/flutter_rust_bridge/guides/logging) for more information. If you implemented logging yourself you might have to migrate your changes. + ## 2.10.0 * Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/guides/miscellaneous/whats-new for what's changed in V2. diff --git a/frb_rust/src/lib.rs b/frb_rust/src/lib.rs index 99aa57ad195..74867e57355 100644 --- a/frb_rust/src/lib.rs +++ b/frb_rust/src/lib.rs @@ -40,6 +40,11 @@ pub use crate::handler::handler::Handler; pub use crate::handler::implementation::handler::DefaultHandler; pub use crate::misc::dart_dynamic::DartDynamic; pub use crate::misc::into_into_dart::IntoIntoDart; +// needed for testing the logging feature +// in a consuming project's lib.rs this would be +// pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +#[cfg(test)] +use crate::misc::logging::test::MockStreamSink as __FrbStreamSinkForLogging; pub use crate::misc::panic_backtrace::{CatchUnwindWithBacktrace, PanicBacktrace}; #[cfg(feature = "user-utils")] pub use crate::misc::user_utils::setup_default_user_utils; From ef47bbfc0bde582d211dc41dc86782e2808546f6 Mon Sep 17 00:00:00 2001 From: patmuk Date: Fri, 20 Jun 2025 10:08:17 +0200 Subject: [PATCH 13/26] injects dependency into lib.rs --- .../codegen/polisher/add_mod_to_lib.rs | 518 +++++++++++++++++- frb_example/dart_build_rs/rust/src/lib.rs | 8 +- frb_example/dart_minimal/rust/src/lib.rs | 8 +- frb_example/deliberate_bad/rust/src/lib.rs | 8 +- frb_example/gallery/rust/src/lib.rs | 8 +- .../integrate_third_party/rust/src/lib.rs | 8 +- frb_example/pure_dart/frb_generated.h | 26 +- .../lib/src/rust/frb_generated.io.dart | 130 ++--- frb_example/pure_dart/rust/src/lib.rs | 9 +- frb_example/pure_dart_pde/rust/src/lib.rs | 9 +- frb_example/rust_ui_counter/src/lib.rs | 8 +- frb_example/rust_ui_todo_list/src/lib.rs | 8 +- 12 files changed, 642 insertions(+), 106 deletions(-) diff --git a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs index 2e1790d0a94..3c372217dbc 100644 --- a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs +++ b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs @@ -1,5 +1,5 @@ use anyhow::*; -use log::{info, warn}; +use log::{debug, info, warn}; use pathdiff::diff_paths; use std::fs; use std::path::Path; @@ -23,14 +23,11 @@ pub(super) fn try_add_mod_to_lib(rust_crate_dir: &Path, rust_output_path: &Path) fn auto_add_mod_to_lib_core(rust_crate_dir: &Path, rust_output_path: &Path) -> Result<()> { let path_src_folder = rust_crate_dir.join("src"); let rust_output_path_relative_to_src_folder = - diff_paths(rust_output_path, path_src_folder.clone()).with_context(|| { - // This will stop the whole generator and tell the users, so we do not care about testing it - // frb-coverage:ignore-start - format!( - "rust_output_path={rust_output_path:?} is unrelated to path_src_folder={path_src_folder:?}", - ) - // frb-coverage:ignore-end - })?; + diff_paths(rust_output_path, path_src_folder.clone()).with_context(|| { + format!( + "rust_output_path={rust_output_path:?} is unrelated to path_src_folder={path_src_folder:?}", + ) + })?; let mod_name = rust_output_path_relative_to_src_folder .file_stem() @@ -39,19 +36,506 @@ fn auto_add_mod_to_lib_core(rust_crate_dir: &Path, rust_output_path: &Path) -> R .context("Not a UTF-8 path")? .to_string() .replace('/', "::"); - let expect_code = format!("mod {mod_name};"); let path_lib_rs = path_src_folder.join("lib.rs"); + let raw_content_lib_rs = fs::read_to_string(&path_lib_rs)?; + let lib_rs_content_normalized = raw_content_lib_rs.replace("\r\n", "\n"); - let raw_content_lib_rs = fs::read_to_string(path_lib_rs.clone())?; - if !raw_content_lib_rs.contains(&expect_code) { - info!("Inject `{}` into {:?}", &expect_code, &path_lib_rs); + let final_content = process_lib_rs_content(&lib_rs_content_normalized, &mod_name); - let comments = " /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */"; - let modified_content_lib_rs = format!("{expect_code}{comments}\n{raw_content_lib_rs}"); - - fs::write(&path_lib_rs, modified_content_lib_rs).unwrap(); + // --- Write back only if content actually changed from the original normalized state, ignoring white spaces --- + if final_content.replace("/n", "") != lib_rs_content_normalized.replace("/n", "") { + fs::write(&path_lib_rs, final_content.as_bytes()).unwrap(); // Write as bytes to preserve LF newlines + } else { + info!("No changes needed to lib.rs. Skipping write."); } Ok(()) } + +fn process_lib_rs_content(initial_content: &str, mod_name: &str) -> String { + const CODE_INJECT_BLOCK_MARKER_START: &str = "// AUTO INJECTED BY flutter_rust_bridge."; + const CODE_INJECT_BLOCK_MARKER_END: &str = "// END of AUTO INJECTED code"; + + let code_to_inject = format!( + "// The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;" + ); + + let code_to_inject_full_block = format!( + "{CODE_INJECT_BLOCK_MARKER_START}\n{code_to_inject}\n{CODE_INJECT_BLOCK_MARKER_END}\n\n" + ); + + // TODO remove this lines after a migration period + // remove FRB's per-v2.10.0 injectedd code + let legacy_frb_injected_code = format!("mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */"); + + let mut in_injected_block = false; + let mut new_code_injected = false; + let mut pre_code_injection_text = String::new(); + let mut output = String::new(); + let mut last_line_was_empty = true; + + debug!("injecting code to lib.rs"); + for line in initial_content.lines() { + // trace!("line is: '{line}'"); + match line.trim() { + "" => { + // Only add empty line if the last line wasn't empty (collapse multiple empty lines) + if !last_line_was_empty { + output.push('\n'); // normalises \r\n to \n + last_line_was_empty = true; + } + } + // Keep config lines (e.g. `#![allow(clippy::new_without_default)]`) on top of the file + trimmed_line if trimmed_line.starts_with("#!") => { + pre_code_injection_text.push_str(trimmed_line); + pre_code_injection_text.push('\n'); + } + trimmed_line if trimmed_line == legacy_frb_injected_code => { + debug!("legacy code, removing"); + last_line_was_empty = false; + } + trimmed_line if trimmed_line == CODE_INJECT_BLOCK_MARKER_START => { + if !in_injected_block { + in_injected_block = true; + } + } + trimmed_line if trimmed_line == CODE_INJECT_BLOCK_MARKER_END => { + if in_injected_block { + if !new_code_injected { + // overwriter old injected code with new one + output.push_str(&_inject_code( + &pre_code_injection_text, + &code_to_inject_full_block, + )); + debug!("INJECT code"); + new_code_injected = true; + } + in_injected_block = false; + last_line_was_empty = true; + } else { + panic!("\nCould not generate code for lib.rs, as the content is wrong (missing injected code start marker '{CODE_INJECT_BLOCK_MARKER_START}'.\nThis is the content:\n'\n{initial_content}\n'"); + } + } + trimmed_line if !in_injected_block => { + // take line outside of injected code and trim it + output.push_str(&format!("{trimmed_line}\n")); + last_line_was_empty = false; + } + _ if in_injected_block => { + // drop the old injected line + } + _ => { + unreachable!() + } + } + // debug!("output is: '{output}'"); + } + if in_injected_block { + panic!("\nCould not generate code for lib.rs, as the content is wrong (missing injected code end marker '{CODE_INJECT_BLOCK_MARKER_END}'.\nThis is the content:\n'\n{initial_content}\n'"); + } + + if !new_code_injected { + output = format!( + "{}{output}", + _inject_code(&pre_code_injection_text, &code_to_inject_full_block) + ); + }; + // have only one neline in the very end + output = format!("{}\n", output.trim_end_matches('\n')); + output +} + +fn _inject_code(pre_code_injection_text: &str, code_to_inject: &str) -> String { + format!( + "{pre_code_injection_text}{}{code_to_inject}", + if pre_code_injection_text.is_empty() { + "" + } else { + "\n" + } + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + // Helper to get the expected new injected block for tests + fn get_expected_new_block(mod_name: &str) -> String { + format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + // The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\n", + ) + } + + fn get_expected_full_file(mod_name: &str) -> String { + format!("{}pub mod api;\n", get_expected_new_block(mod_name)) + } + + // --- Test Cases --- + + #[test] + fn test_inject_into_empty_lib_rs() { + let initial_content = ""; + let mod_name = "frb_generated"; + let mut result_content = process_lib_rs_content(initial_content, mod_name); + // makes assert easier + result_content.push('\n'); + assert_eq!(result_content, get_expected_new_block(mod_name)); + } + + #[test] + fn test_inject_into_existing_lib_rs_without_newline_at_end() { + let initial_content = "pub mod api;"; // No trailing newline + let mod_name = "frb_generated"; + let result_content = process_lib_rs_content(initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + fn test_inject_into_existing_lib_rs_with_newline_at_end() { + let initial_content = "pub mod api;\n"; // With trailing newline + let mod_name = "frb_generated"; + let result_content = process_lib_rs_content(initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + #[test] + fn test_inject_into_existing_lib_rs_with_multiple_newlines_at_end() { + let initial_content = "pub mod api;\n\n\n"; // With trailing newline + let mod_name = "frb_generated"; + let result_content = process_lib_rs_content(initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + #[test] + fn test_inject_into_existing_lib_rs_with_multiple_newlines() { + let initial_content = "\n\n\npub mod api;\n\n\n"; // With trailing newline + let mod_name = "frb_generated"; + let result_content = process_lib_rs_content(initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + fn test_no_change_if_already_up_to_date_new_format() { + let mod_name = "frb_generated"; + let initial_content = get_expected_full_file(mod_name); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, initial_content); // Should remain unchanged + } + + #[test] + fn test_leave_at_top() { + let mod_name = "frb_generated"; + let result_content = process_lib_rs_content(&get_expected_full_file(mod_name), mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); // Should remain unchanged + } + + #[test] + fn test_replace_old_format_with_new_format() { + let mod_name = "frb_generated"; + let old_injected_line = format!( + "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + ); + let initial_content = format!( + "pub mod api;\n{old_injected_line}\nother code;" // Old format embedded + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + + let expected_code = format!( + "{}pub mod api;\nother code;\n", // Old format removed, new prepended, remaining code at end + get_expected_new_block(mod_name) + ); + assert_eq!(result_content, expected_code); + } + + #[test] + fn test_replace_only_old_format_file() { + let mod_name = "frb_generated"; + let old_injected_line = format!( + "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + ); + let initial_content = format!("{old_injected_line}\n"); // File contains only the old format + let mut result_content = process_lib_rs_content(&initial_content, mod_name); + + // Should be replaced by only the new block + // push one more \n to make comparission easier + result_content.push('\n'); + assert_eq!(result_content, get_expected_new_block(mod_name)); + } + + #[test] + fn test_idempotent_after_replacement() { + let mod_name = "frb_generated"; + let old_injected_line = format!( + "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + ); + let initial_content = format!("pub mod api;\n{old_injected_line}\n"); + + let content_after_first_run = process_lib_rs_content(&initial_content, mod_name); // First run: replace old with new + let content_after_second_run = process_lib_rs_content(&content_after_first_run, mod_name); // Second run: should not change + + assert_eq!(content_after_first_run, content_after_second_run); + // assert_eq!(content_after_second_run, get_expected_full_file(mod_name)); + } + + #[test] + fn test_multiple_old_formats() { + let mod_name = "frb_generated"; + let old_injected_line = format!( + "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */"); + let initial_content = format!( + "{old_injected_line}\npub mod api;\n{old_injected_line}\n" // Multiple old formats + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + fn test_multpipe_code_markers() { + let mod_name = "frb_generated"; + let initial_content = format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + pub mod api;\n + // AUTO INJECTED BY flutter_rust_bridge.\n\ + The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + #[should_panic( + expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code end marker '// END of AUTO INJECTED code'.\nThis is the content:\n" + )] + fn test_incomplete_code_markers_only_start() { + let mod_name = "frb_generated"; + let initial_content = format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + pub mod api;\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + #[should_panic( + expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code start marker '// AUTO INJECTED BY flutter_rust_bridge.'.\nThis is the content:\n" + )] + fn test_incomplete_code_markers_only_end() { + let mod_name = "frb_generated"; + let initial_content = format!( + "mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + pub mod api;\n" + ); + let _ = process_lib_rs_content(&initial_content, mod_name); + } + + #[test] + #[should_panic( + expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code end marker '// END of AUTO INJECTED code'.\nThis is the content:\n" + )] + fn test_multiple_start_code_markers_without_end() { + let mod_name = "frb_generated"; + let initial_content = format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + pub mod api;\n + // AUTO INJECTED BY flutter_rust_bridge.\n\ + The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + #[test] + #[should_panic( + expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code start marker '// AUTO INJECTED BY flutter_rust_bridge.'.\nThis is the content:\n" + )] + fn test_multiple_end_code_markers_without_start() { + let mod_name = "frb_generated"; + let initial_content = format!( + "mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + pub mod api;\n + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + fn test_new_format_old_content() { + let mod_name = "frb_generated"; + let initial_content = format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + pub mod api;\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + fn test_replace_old_generated_content_with_new() { + let mod_name = "frb_generated"; + let initial_content = format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + This are outdated lines, to be replaced!\n\ + And another old line.\n\ + If these are still inside, the test fails!\n\ + // END of AUTO INJECTED code\n\ + pub mod api;\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + assert_eq!(result_content, get_expected_full_file(mod_name)); + } + + #[test] + fn test_mixed_formats_and_other_content_replace_at_place() { + let mod_name = "frb_generated"; + let old_injected_line = format!( + "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + ); + let existing_new_block = get_expected_new_block(mod_name); + + let initial_content = format!( + "// Some header comments\n\ + {existing_new_block}\n\ + \n\ + pub mod feature_a;\n\ + {old_injected_line}\n\n\ + pub mod feature_b;\n\n\ + {old_injected_line}\n\ + // Some footer comments\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + + let expected_code = format!( + "// Some header comments\n\ + {existing_new_block}\ + pub mod feature_a;\n\n\ + pub mod feature_b;\n\n\ + // Some footer comments\n" + ); + assert_eq!(result_content, expected_code); + } + + #[test] + fn test_only_empty_lines_differ() { + let mod_name = "frb_generated"; + + let initial_content = format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + // The following lines may not be accurate; change them according to your needs.\n\ + mod {mod_name};\n\ + // this export is needed for logging\n\ + pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + \n\ + // AUTO-GENERATED FROM frb_example/pure_dart, DO NOT EDIT\n\ + pub mod api;\n\ + mod auxiliary;\n\ + mod deliberate_name_conflict;\n\ + pub fn function_at_lib_rs()\n\ + \n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + + assert_eq!( + result_content.replace("\n", ""), + initial_content.replace("\n", "") + ); + } + #[test] + fn test_keep_directive_on_top() { + let mod_name = "frb_generated"; + + let initial_content = " + #![allow(clippy::new_without_default)] + pub mod app; + " + .to_string(); + let result_content = process_lib_rs_content(&initial_content, mod_name); + let expected_code = format!( + "#![allow(clippy::new_without_default)]\n\ + \n\ + // AUTO INJECTED BY flutter_rust_bridge.\n\ + // The following lines may not be accurate; change them according to your needs.\n\ + mod frb_generated;\n\ + // this export is needed for logging\n\ + pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + \n\ + pub mod app;\n" + ); + assert_eq!(result_content, expected_code); + } + #[test] + fn test_remove_top_newline() { + let mod_name = "frb_generated"; + let initial_content = format!( + "\n\ + #![allow(clippy::new_without_default)]\n\ + \n\ + // AUTO INJECTED BY flutter_rust_bridge.\n\ + // The following lines may not be accurate; change them according to your needs.\n\ + mod frb_generated;\n\ + // this export is needed for logging\n\ + pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + \n\ + pub mod app;\n" + ); + let result_content = process_lib_rs_content(&initial_content, mod_name); + let expected_code = format!( + "#![allow(clippy::new_without_default)]\n\ + \n\ + // AUTO INJECTED BY flutter_rust_bridge.\n\ + // The following lines may not be accurate; change them according to your needs.\n\ + mod frb_generated;\n\ + // this export is needed for logging\n\ + pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ + // END of AUTO INJECTED code\n\ + \n\ + pub mod app;\n" + ); + assert_eq!(result_content, expected_code); + } +} diff --git a/frb_example/dart_build_rs/rust/src/lib.rs b/frb_example/dart_build_rs/rust/src/lib.rs index 9360602722d..a57332801d0 100644 --- a/frb_example/dart_build_rs/rust/src/lib.rs +++ b/frb_example/dart_build_rs/rust/src/lib.rs @@ -1,2 +1,8 @@ +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + pub mod api; -mod frb_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ diff --git a/frb_example/dart_minimal/rust/src/lib.rs b/frb_example/dart_minimal/rust/src/lib.rs index 9360602722d..a57332801d0 100644 --- a/frb_example/dart_minimal/rust/src/lib.rs +++ b/frb_example/dart_minimal/rust/src/lib.rs @@ -1,2 +1,8 @@ +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + pub mod api; -mod frb_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ diff --git a/frb_example/deliberate_bad/rust/src/lib.rs b/frb_example/deliberate_bad/rust/src/lib.rs index 9360602722d..a57332801d0 100644 --- a/frb_example/deliberate_bad/rust/src/lib.rs +++ b/frb_example/deliberate_bad/rust/src/lib.rs @@ -1,2 +1,8 @@ +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + pub mod api; -mod frb_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ diff --git a/frb_example/gallery/rust/src/lib.rs b/frb_example/gallery/rust/src/lib.rs index bd0019a2ede..88b0d574266 100644 --- a/frb_example/gallery/rust/src/lib.rs +++ b/frb_example/gallery/rust/src/lib.rs @@ -1,3 +1,9 @@ -pub mod api; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod api; pub mod ignore_me; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ diff --git a/frb_example/integrate_third_party/rust/src/lib.rs b/frb_example/integrate_third_party/rust/src/lib.rs index b464c85de89..a2d97f069b7 100644 --- a/frb_example/integrate_third_party/rust/src/lib.rs +++ b/frb_example/integrate_third_party/rust/src/lib.rs @@ -1,3 +1,9 @@ +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + pub mod api; -mod frb_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ pub mod third_party; diff --git a/frb_example/pure_dart/frb_generated.h b/frb_example/pure_dart/frb_generated.h index 31695d43ff6..2c2df9893b9 100644 --- a/frb_example/pure_dart/frb_generated.h +++ b/frb_example/pure_dart/frb_generated.h @@ -18,11 +18,6 @@ typedef struct _Dart_Handle* Dart_Handle; #define CONST_WITH_EXPLICIT_IGNORE_SHOULD_IGNORE 42 -typedef struct benchmark_raw_list_prim_u_8 { - uint8_t *ptr; - int32_t len; -} benchmark_raw_list_prim_u_8; - typedef struct wire_cst_list_prim_u_8_strict { uint8_t *ptr; int32_t len; @@ -2960,6 +2955,11 @@ typedef struct wire_cst_list_sum_with_twin_sync { int32_t len; } wire_cst_list_sum_with_twin_sync; +typedef struct benchmark_raw_list_prim_u_8 { + uint8_t *ptr; + int32_t len; +} benchmark_raw_list_prim_u_8; + typedef struct wire_cst_another_macro_struct_twin_normal { int32_t data; int32_t non_final_data; @@ -3534,14 +3534,6 @@ typedef struct wire_cst_vec_of_primitive_pack_twin_sync { struct wire_cst_list_bool *bool_list; } wire_cst_vec_of_primitive_pack_twin_sync; -void benchmark_raw_void_sync(void); - -struct benchmark_raw_list_prim_u_8 benchmark_raw_new_list_prim_u_8(int32_t len); - -int32_t benchmark_raw_input_bytes(struct benchmark_raw_list_prim_u_8 bytes); - -void benchmark_raw_output_bytes(int64_t port, int32_t message_id, int32_t size); - WireSyncRust2DartDco frbgen_frb_example_pure_dart_wire__crate__api__misc_no_twin_example_a__CONST_ARRAY_TWIN_NORMAL(void); WireSyncRust2DartDco frbgen_frb_example_pure_dart_wire__crate__api__misc_no_twin_example_a__CONST_INT_TWIN_NORMAL(void); @@ -15497,6 +15489,14 @@ struct wire_cst_list_weekdays_twin_normal *frbgen_frb_example_pure_dart_cst_new_ struct wire_cst_list_weekdays_twin_rust_async *frbgen_frb_example_pure_dart_cst_new_list_weekdays_twin_rust_async(int32_t len); struct wire_cst_list_weekdays_twin_sync *frbgen_frb_example_pure_dart_cst_new_list_weekdays_twin_sync(int32_t len); + +void benchmark_raw_void_sync(void); + +struct benchmark_raw_list_prim_u_8 benchmark_raw_new_list_prim_u_8(int32_t len); + +int32_t benchmark_raw_input_bytes(struct benchmark_raw_list_prim_u_8 bytes); + +void benchmark_raw_output_bytes(int64_t port, int32_t message_id, int32_t size); static int64_t dummy_method_to_enforce_bundling(void) { int64_t dummy_var = 0; dummy_var ^= ((int64_t) (void*) frbgen_frb_example_pure_dart_cst_new_box_application_env); diff --git a/frb_example/pure_dart/lib/src/rust/frb_generated.io.dart b/frb_example/pure_dart/lib/src/rust/frb_generated.io.dart index af338c86466..899b2a0bedf 100644 --- a/frb_example/pure_dart/lib/src/rust/frb_generated.io.dart +++ b/frb_example/pure_dart/lib/src/rust/frb_generated.io.dart @@ -43586,64 +43586,6 @@ class RustLibWire implements BaseWire { late final _store_dart_post_cobject = _store_dart_post_cobjectPtr .asFunction(); - void benchmark_raw_void_sync() { - return _benchmark_raw_void_sync(); - } - - late final _benchmark_raw_void_syncPtr = - _lookup>( - 'benchmark_raw_void_sync'); - late final _benchmark_raw_void_sync = - _benchmark_raw_void_syncPtr.asFunction(); - - benchmark_raw_list_prim_u_8 benchmark_raw_new_list_prim_u_8( - int len, - ) { - return _benchmark_raw_new_list_prim_u_8( - len, - ); - } - - late final _benchmark_raw_new_list_prim_u_8Ptr = _lookup< - ffi.NativeFunction>( - 'benchmark_raw_new_list_prim_u_8'); - late final _benchmark_raw_new_list_prim_u_8 = - _benchmark_raw_new_list_prim_u_8Ptr - .asFunction(); - - int benchmark_raw_input_bytes( - benchmark_raw_list_prim_u_8 bytes, - ) { - return _benchmark_raw_input_bytes( - bytes, - ); - } - - late final _benchmark_raw_input_bytesPtr = _lookup< - ffi.NativeFunction>( - 'benchmark_raw_input_bytes'); - late final _benchmark_raw_input_bytes = _benchmark_raw_input_bytesPtr - .asFunction(); - - void benchmark_raw_output_bytes( - int port, - int message_id, - int size, - ) { - return _benchmark_raw_output_bytes( - port, - message_id, - size, - ); - } - - late final _benchmark_raw_output_bytesPtr = _lookup< - ffi - .NativeFunction>( - 'benchmark_raw_output_bytes'); - late final _benchmark_raw_output_bytes = - _benchmark_raw_output_bytesPtr.asFunction(); - WireSyncRust2DartDco wire__crate__api__misc_no_twin_example_a__CONST_ARRAY_TWIN_NORMAL() { return _wire__crate__api__misc_no_twin_example_a__CONST_ARRAY_TWIN_NORMAL(); @@ -119475,6 +119417,64 @@ class RustLibWire implements BaseWire { _cst_new_list_weekdays_twin_syncPtr.asFunction< ffi.Pointer Function(int)>(); + void benchmark_raw_void_sync() { + return _benchmark_raw_void_sync(); + } + + late final _benchmark_raw_void_syncPtr = + _lookup>( + 'benchmark_raw_void_sync'); + late final _benchmark_raw_void_sync = + _benchmark_raw_void_syncPtr.asFunction(); + + benchmark_raw_list_prim_u_8 benchmark_raw_new_list_prim_u_8( + int len, + ) { + return _benchmark_raw_new_list_prim_u_8( + len, + ); + } + + late final _benchmark_raw_new_list_prim_u_8Ptr = _lookup< + ffi.NativeFunction>( + 'benchmark_raw_new_list_prim_u_8'); + late final _benchmark_raw_new_list_prim_u_8 = + _benchmark_raw_new_list_prim_u_8Ptr + .asFunction(); + + int benchmark_raw_input_bytes( + benchmark_raw_list_prim_u_8 bytes, + ) { + return _benchmark_raw_input_bytes( + bytes, + ); + } + + late final _benchmark_raw_input_bytesPtr = _lookup< + ffi.NativeFunction>( + 'benchmark_raw_input_bytes'); + late final _benchmark_raw_input_bytes = _benchmark_raw_input_bytesPtr + .asFunction(); + + void benchmark_raw_output_bytes( + int port, + int message_id, + int size, + ) { + return _benchmark_raw_output_bytes( + port, + message_id, + size, + ); + } + + late final _benchmark_raw_output_bytesPtr = _lookup< + ffi + .NativeFunction>( + 'benchmark_raw_output_bytes'); + late final _benchmark_raw_output_bytes = + _benchmark_raw_output_bytesPtr.asFunction(); + int dummy_method_to_enforce_bundling() { return _dummy_method_to_enforce_bundling(); } @@ -119495,13 +119495,6 @@ typedef DartDartPostCObjectFnTypeFunction = bool Function( typedef DartPort = ffi.Int64; typedef DartDartPort = int; -final class benchmark_raw_list_prim_u_8 extends ffi.Struct { - external ffi.Pointer ptr; - - @ffi.Int32() - external int len; -} - final class wire_cst_list_prim_u_8_strict extends ffi.Struct { external ffi.Pointer ptr; @@ -123486,6 +123479,13 @@ final class wire_cst_list_sum_with_twin_sync extends ffi.Struct { external int len; } +final class benchmark_raw_list_prim_u_8 extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + final class wire_cst_another_macro_struct_twin_normal extends ffi.Struct { @ffi.Int32() external int data; diff --git a/frb_example/pure_dart/rust/src/lib.rs b/frb_example/pure_dart/rust/src/lib.rs index a94f0a8caf6..c8257427fe4 100644 --- a/frb_example/pure_dart/rust/src/lib.rs +++ b/frb_example/pure_dart/rust/src/lib.rs @@ -1,6 +1,11 @@ +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + pub mod api; mod auxiliary; mod deliberate_name_conflict; -mod frb_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ - pub fn function_at_lib_rs() {} diff --git a/frb_example/pure_dart_pde/rust/src/lib.rs b/frb_example/pure_dart_pde/rust/src/lib.rs index 0df02943985..8a28dc583ff 100644 --- a/frb_example/pure_dart_pde/rust/src/lib.rs +++ b/frb_example/pure_dart_pde/rust/src/lib.rs @@ -1,8 +1,13 @@ // AUTO-GENERATED FROM frb_example/pure_dart, DO NOT EDIT +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + pub mod api; mod auxiliary; mod deliberate_name_conflict; -mod frb_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ - pub fn function_at_lib_rs() {} diff --git a/frb_example/rust_ui_counter/src/lib.rs b/frb_example/rust_ui_counter/src/lib.rs index 028e2a6043f..1d1ed931785 100644 --- a/frb_example/rust_ui_counter/src/lib.rs +++ b/frb_example/rust_ui_counter/src/lib.rs @@ -1,4 +1,10 @@ #![allow(clippy::new_without_default)] -pub mod app; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod app; diff --git a/frb_example/rust_ui_todo_list/src/lib.rs b/frb_example/rust_ui_todo_list/src/lib.rs index 028e2a6043f..1d1ed931785 100644 --- a/frb_example/rust_ui_todo_list/src/lib.rs +++ b/frb_example/rust_ui_todo_list/src/lib.rs @@ -1,4 +1,10 @@ #![allow(clippy::new_without_default)] -pub mod app; +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod app; From 0f20ebd80549d768d0031600bf73e93f8171fd69 Mon Sep 17 00:00:00 2001 From: patmuk Date: Wed, 25 Jun 2025 15:43:57 +0200 Subject: [PATCH 14/26] adds new example project for logging --- Cargo.toml | 1 + frb_example/dart_logging/.gitignore | 44 ++ frb_example/dart_logging/README.md | 3 + .../dart_logging/analysis_options.yaml | 3 + frb_example/dart_logging/build.dart | 3 + .../dart_logging/flutter_rust_bridge.yaml | 11 + frb_example/dart_logging/frb_generated.h | 1 + frb_example/dart_logging/lib/main.dart | 12 + .../lib/src/rust/api/minimal_logging.dart | 170 +++++ .../lib/src/rust/frb_generated.dart | 648 ++++++++++++++++ .../lib/src/rust/frb_generated.io.dart | 186 +++++ .../lib/src/rust/frb_generated.web.dart | 186 +++++ frb_example/dart_logging/pubspec.lock | 688 +++++++++++++++++ frb_example/dart_logging/pubspec.yaml | 20 + frb_example/dart_logging/rust/Cargo.lock | 712 ++++++++++++++++++ frb_example/dart_logging/rust/Cargo.toml | 15 + .../rust/src/api/minimal_logging.rs | 13 + frb_example/dart_logging/rust/src/api/mod.rs | 1 + .../dart_logging/rust/src/frb_generated.rs | 686 +++++++++++++++++ frb_example/dart_logging/rust/src/lib.rs | 8 + .../test/dart_valgrind_test_entrypoint.dart | 5 + .../test/dart_web_test_entrypoint.dart | 9 + .../dart_logging/test/empty_entrypoint.dart | 1 + .../dart_logging/test/logging_test.dart | 19 + frb_example/dart_logging/web/.gitignore | 1 + .../web/experiment_call_wasm_from_js.html | 30 + .../lib/src/makefile_dart/consts.dart | 3 + website/docs/guides/contributing/overview.md | 3 +- 28 files changed, 3481 insertions(+), 1 deletion(-) create mode 100644 frb_example/dart_logging/.gitignore create mode 100644 frb_example/dart_logging/README.md create mode 100644 frb_example/dart_logging/analysis_options.yaml create mode 100644 frb_example/dart_logging/build.dart create mode 100644 frb_example/dart_logging/flutter_rust_bridge.yaml create mode 100644 frb_example/dart_logging/frb_generated.h create mode 100644 frb_example/dart_logging/lib/main.dart create mode 100644 frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart create mode 100644 frb_example/dart_logging/lib/src/rust/frb_generated.dart create mode 100644 frb_example/dart_logging/lib/src/rust/frb_generated.io.dart create mode 100644 frb_example/dart_logging/lib/src/rust/frb_generated.web.dart create mode 100644 frb_example/dart_logging/pubspec.lock create mode 100644 frb_example/dart_logging/pubspec.yaml create mode 100644 frb_example/dart_logging/rust/Cargo.lock create mode 100644 frb_example/dart_logging/rust/Cargo.toml create mode 100644 frb_example/dart_logging/rust/src/api/minimal_logging.rs create mode 100644 frb_example/dart_logging/rust/src/api/mod.rs create mode 100644 frb_example/dart_logging/rust/src/frb_generated.rs create mode 100644 frb_example/dart_logging/rust/src/lib.rs create mode 100644 frb_example/dart_logging/test/dart_valgrind_test_entrypoint.dart create mode 100644 frb_example/dart_logging/test/dart_web_test_entrypoint.dart create mode 100644 frb_example/dart_logging/test/empty_entrypoint.dart create mode 100644 frb_example/dart_logging/test/logging_test.dart create mode 100644 frb_example/dart_logging/web/.gitignore create mode 100644 frb_example/dart_logging/web/experiment_call_wasm_from_js.html diff --git a/Cargo.toml b/Cargo.toml index 059c815ce63..04117f0f9f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ exclude = [ # Exclude example packages to ensure the example mimics how a typical user will use it. # For example, the `target` directory is different with and without workspaces. "frb_example/dart_minimal/rust", + "frb_example/dart_logging/rust", "frb_example/deliberate_bad/rust", "frb_example/flutter_via_create/rust", "frb_example/flutter_via_integrate/rust", diff --git a/frb_example/dart_logging/.gitignore b/frb_example/dart_logging/.gitignore new file mode 100644 index 00000000000..24476c5d1eb --- /dev/null +++ b/frb_example/dart_logging/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/frb_example/dart_logging/README.md b/frb_example/dart_logging/README.md new file mode 100644 index 00000000000..e67e94a370e --- /dev/null +++ b/frb_example/dart_logging/README.md @@ -0,0 +1,3 @@ +## Dart minimal logging example for `flutter_rust_bridge` + +Please visit the main documentation or open an issue for more information. diff --git a/frb_example/dart_logging/analysis_options.yaml b/frb_example/dart_logging/analysis_options.yaml new file mode 100644 index 00000000000..e6e61117cac --- /dev/null +++ b/frb_example/dart_logging/analysis_options.yaml @@ -0,0 +1,3 @@ +analyzer: + exclude: + - rust/target/**.dart # contains dumped debug info, instead of normal code \ No newline at end of file diff --git a/frb_example/dart_logging/build.dart b/frb_example/dart_logging/build.dart new file mode 100644 index 00000000000..1df95807a05 --- /dev/null +++ b/frb_example/dart_logging/build.dart @@ -0,0 +1,3 @@ +import 'package:flutter_rust_bridge_utils/flutter_rust_bridge_utils.dart'; + +void main(List args) async => simpleBuild(args); diff --git a/frb_example/dart_logging/flutter_rust_bridge.yaml b/frb_example/dart_logging/flutter_rust_bridge.yaml new file mode 100644 index 00000000000..f98e28e477f --- /dev/null +++ b/frb_example/dart_logging/flutter_rust_bridge.yaml @@ -0,0 +1,11 @@ +# See `pure_dart` example for comments on the configs +rust_input: rust/src/api/**/*.rs +dart_output: lib/src/rust +c_output: frb_generated.h +dump_all: true +local: true + +# TODO temp +#full_dep: true +#enable_lifetime: true +#stop_on_error: true diff --git a/frb_example/dart_logging/frb_generated.h b/frb_example/dart_logging/frb_generated.h new file mode 100644 index 00000000000..ad87ade833f --- /dev/null +++ b/frb_example/dart_logging/frb_generated.h @@ -0,0 +1 @@ +// Nothing when using full_dep=false mode \ No newline at end of file diff --git a/frb_example/dart_logging/lib/main.dart b/frb_example/dart_logging/lib/main.dart new file mode 100644 index 00000000000..70513b31fde --- /dev/null +++ b/frb_example/dart_logging/lib/main.dart @@ -0,0 +1,12 @@ +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:frb_example_dart_logging/src/rust/api/minimal_logging.dart'; +import 'package:frb_example_dart_logging/src/rust/frb_generated.dart'; + +final LOGGER = FRBLogger.initLogger(maxLogLevel: LogLevel.trace); + +// If you are developing a binary program, you may want to put it in `bin/something.dart` +Future main() async { + await RustLib.init(); + LOGGER.trace( + 'Call Rust and get: 100+200 = ${await minimalAdder(a: 100, b: 200)}'); +} diff --git a/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart b/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart new file mode 100644 index 00000000000..cec3018046d --- /dev/null +++ b/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart @@ -0,0 +1,170 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.10.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:logging/logging.dart'; + +// These functions are ignored because they are not marked as `pub`: `_construct_default_message`, `_default_log_fn`, `_default_logger_name`, `_default_max_log_level`, `from_u16`, `to_u16` +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `enabled`, `flush`, `from`, `log` + +String rootLoggerName() => + RustLib.instance.api.crateApiMinimalLoggingRootLoggerName(); + +String maxLogLevel() => + RustLib.instance.api.crateApiMinimalLoggingMaxLogLevel(); + +/// this is the call for logging (from Rust and Dart (as logFn)) +void logFn({required MirLogRecord record}) => + RustLib.instance.api.crateApiMinimalLoggingLogFn(record: record); + +/// uses custom type translation to translate between log::LogLevel and Dart:logging::Level +/// loglevel is represented by a number, so that we don't need to put \import `import 'package:logging/logging.dart';` +/// into the dart preamble in flutter_rust_bridge.yaml +Stream initializeLog2Dart({required int maxLogLevel}) => + RustLib.instance.api + .crateApiMinimalLoggingInitializeLog2Dart(maxLogLevel: maxLogLevel); + +Future minimalAdder({required int a, required int b}) => + RustLib.instance.api.crateApiMinimalLoggingMinimalAdder(a: a, b: b); + +class FRBLogger { + final RustStreamSink streamSink; + + const FRBLogger({ + required this.streamSink, + }); + + // HINT: Make it `#[frb(sync)]` to let it become the default constructor of Dart class. + static Future newInstance() => + RustLib.instance.api.crateApiMinimalLoggingFrbLoggerNew(); + + static FRBDartLogger initLogger( + {String name = 'FRBLogger', + LogLevel maxLogLevel = LogLevel.info, + Function({required MirLogRecord record}) customLogFunction = logFn}) { + //initialize the rust side + int maxLogLevelNumber = maxLogLevel.levelNumberThreshold; + Stream stream = + initializeLog2Dart(maxLogLevel: maxLogLevelNumber); + + // Functions for type conversion for interaction with frb_dart/utils/frb_logging.dart + // Wrap logFn to match `void Function({required dynamic record})` + void Function({required dynamic record}) wrappedLogFn = + ({required dynamic record}) { + // Safely cast `dynamic` record back to `MirLogRecord` for the original `logFn` + logFn(record: record as MirLogRecord); + }; + // Wrap fromDartLogRecord to match `dynamic Function(LogRecord record)` + MirLogRecord Function(LogRecord record) wrappedFromDartLogRecord = + (LogRecord record) { + return MirLogRecord.fromDartLogRecord(record); + }; + // Wrap customLogFunction if provided, to match `void Function({required dynamic record})?` + void Function({required dynamic record})? wrappedCustomLogFunction; + wrappedCustomLogFunction = ({required dynamic record}) { + customLogFunction(record: record as MirLogRecord); + }; + + return FRBDartLogger.initAndGetSingleton( + streamSink: stream, + name: name, + logFn: wrappedLogFn, + fromDartLogRecord: wrappedFromDartLogRecord, + maxLogLevel: maxLogLevel, + customLogFunction: wrappedCustomLogFunction, + ); + } + + static FRBDartLogger getLogger([String? name]) { + return FRBDartLogger.getLogger(name); + } + + @override + int get hashCode => streamSink.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is FRBLogger && + runtimeType == other.runtimeType && + streamSink == other.streamSink; +} + +/// mapping log crate's [Record](https://docs.rs/log/latest/log/struct.Record.html) to dart's Logger [LogRecord](https://pub.dev/documentation/logging/latest/logging/LogRecord-class.html). +/// intermediary struct to avoid Record's lifetimes +class MirLogRecord { + final int levelNumber; + final String levelName; + final String message; + final String loggerName; + final String timestamp; + final bool rustLog; + final String? modulePath; + final String? fileName; + final int? lineNumber; + + const MirLogRecord({ + required this.levelNumber, + required this.levelName, + required this.message, + required this.loggerName, + required this.timestamp, + required this.rustLog, + this.modulePath, + this.fileName, + this.lineNumber, + }); + + static MirLogRecord fromDartLogRecord(LogRecord record) { + return MirLogRecord( + message: record.message, + levelNumber: record.level.value, + levelName: LogLevel.fromLoggingLevel(record.level).name.toUpperCase(), + timestamp: record.time.toString(), + loggerName: record.loggerName, + rustLog: false, + ); + } + + static LogRecord toDartLogRecordFromMir(MirLogRecord record) { + return LogRecord( + LogLevel.fromString(record.levelName).toLoggingLevel(), + record.message, + record.loggerName, + ); + } + + LogRecord toDartLogRecord() { + return toDartLogRecordFromMir(this); + } + + @override + int get hashCode => + levelNumber.hashCode ^ + levelName.hashCode ^ + message.hashCode ^ + loggerName.hashCode ^ + timestamp.hashCode ^ + rustLog.hashCode ^ + modulePath.hashCode ^ + fileName.hashCode ^ + lineNumber.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is MirLogRecord && + runtimeType == other.runtimeType && + levelNumber == other.levelNumber && + levelName == other.levelName && + message == other.message && + loggerName == other.loggerName && + timestamp == other.timestamp && + rustLog == other.rustLog && + modulePath == other.modulePath && + fileName == other.fileName && + lineNumber == other.lineNumber; +} diff --git a/frb_example/dart_logging/lib/src/rust/frb_generated.dart b/frb_example/dart_logging/lib/src/rust/frb_generated.dart new file mode 100644 index 00000000000..46eba3f38ed --- /dev/null +++ b/frb_example/dart_logging/lib/src/rust/frb_generated.dart @@ -0,0 +1,648 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.10.0. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +import 'api/minimal_logging.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'frb_generated.dart'; +import 'frb_generated.io.dart' + if (dart.library.js_interop) 'frb_generated.web.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +/// Main entrypoint of the Rust API +class RustLib extends BaseEntrypoint { + @internal + static final instance = RustLib._(); + + RustLib._(); + + /// Initialize flutter_rust_bridge + static Future init({ + RustLibApi? api, + BaseHandler? handler, + ExternalLibrary? externalLibrary, + bool forceSameCodegenVersion = true, + }) async { + await instance.initImpl( + api: api, + handler: handler, + externalLibrary: externalLibrary, + forceSameCodegenVersion: forceSameCodegenVersion, + ); + } + + /// Initialize flutter_rust_bridge in mock mode. + /// No libraries for FFI are loaded. + static void initMock({ + required RustLibApi api, + }) { + instance.initMockImpl( + api: api, + ); + } + + /// Dispose flutter_rust_bridge + /// + /// The call to this function is optional, since flutter_rust_bridge (and everything else) + /// is automatically disposed when the app stops. + static void dispose() => instance.disposeImpl(); + + @override + ApiImplConstructor get apiImplConstructor => + RustLibApiImpl.new; + + @override + WireConstructor get wireConstructor => + RustLibWire.fromExternalLibrary; + + @override + Future executeRustInitializers() async { + await api.crateApiMinimalLoggingInitApp(); + } + + @override + ExternalLibraryLoaderConfig get defaultExternalLibraryLoaderConfig => + kDefaultExternalLibraryLoaderConfig; + + @override + String get codegenVersion => '2.10.0'; + + @override + int get rustContentHash => 1044248026; + + static const kDefaultExternalLibraryLoaderConfig = + ExternalLibraryLoaderConfig( + stem: 'frb_example_dart_logging', + ioDirectory: 'rust/target/release/', + webPrefix: 'pkg/', + ); +} + +abstract class RustLibApi extends BaseApi { + Future crateApiMinimalLoggingFrbLoggerNew(); + + Future crateApiMinimalLoggingInitApp(); + + Stream crateApiMinimalLoggingInitializeLog2Dart( + {required int maxLogLevel}); + + void crateApiMinimalLoggingLogFn({required MirLogRecord record}); + + String crateApiMinimalLoggingMaxLogLevel(); + + Future crateApiMinimalLoggingMinimalAdder( + {required int a, required int b}); + + String crateApiMinimalLoggingRootLoggerName(); +} + +class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { + RustLibApiImpl({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + @override + Future crateApiMinimalLoggingFrbLoggerNew() { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 1, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_frb_logger, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingFrbLoggerNewConstMeta, + argValues: [], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMinimalLoggingFrbLoggerNewConstMeta => + const TaskConstMeta( + debugName: "frb_logger_new", + argNames: [], + ); + + @override + Future crateApiMinimalLoggingInitApp() { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 2, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingInitAppConstMeta, + argValues: [], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMinimalLoggingInitAppConstMeta => + const TaskConstMeta( + debugName: "init_app", + argNames: [], + ); + + @override + Stream crateApiMinimalLoggingInitializeLog2Dart( + {required int maxLogLevel}) { + final logStream = RustStreamSink(); + unawaited(handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_StreamSink_mir_log_record_Sse(logStream, serializer); + sse_encode_u_16(maxLogLevel, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 3, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingInitializeLog2DartConstMeta, + argValues: [logStream, maxLogLevel], + apiImpl: this, + ))); + return logStream.stream; + } + + TaskConstMeta get kCrateApiMinimalLoggingInitializeLog2DartConstMeta => + const TaskConstMeta( + debugName: "initialize_log_2_dart", + argNames: ["logStream", "maxLogLevel"], + ); + + @override + void crateApiMinimalLoggingLogFn({required MirLogRecord record}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_box_autoadd_mir_log_record(record, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 4)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingLogFnConstMeta, + argValues: [record], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMinimalLoggingLogFnConstMeta => + const TaskConstMeta( + debugName: "log_fn", + argNames: ["record"], + ); + + @override + String crateApiMinimalLoggingMaxLogLevel() { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 5)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_String, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingMaxLogLevelConstMeta, + argValues: [], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMinimalLoggingMaxLogLevelConstMeta => + const TaskConstMeta( + debugName: "max_log_level", + argNames: [], + ); + + @override + Future crateApiMinimalLoggingMinimalAdder( + {required int a, required int b}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_i_32(a, serializer); + sse_encode_i_32(b, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 6, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_i_32, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingMinimalAdderConstMeta, + argValues: [a, b], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMinimalLoggingMinimalAdderConstMeta => + const TaskConstMeta( + debugName: "minimal_adder", + argNames: ["a", "b"], + ); + + @override + String crateApiMinimalLoggingRootLoggerName() { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 7)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_String, + decodeErrorData: null, + ), + constMeta: kCrateApiMinimalLoggingRootLoggerNameConstMeta, + argValues: [], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMinimalLoggingRootLoggerNameConstMeta => + const TaskConstMeta( + debugName: "root_logger_name", + argNames: [], + ); + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return AnyhowException(raw as String); + } + + @protected + RustStreamSink dco_decode_StreamSink_mir_log_record_Sse( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + throw UnimplementedError(); + } + + @protected + String dco_decode_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as String; + } + + @protected + bool dco_decode_bool(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as bool; + } + + @protected + MirLogRecord dco_decode_box_autoadd_mir_log_record(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_mir_log_record(raw); + } + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + FRBLogger dco_decode_frb_logger(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 1) + throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return FRBLogger( + streamSink: dco_decode_StreamSink_mir_log_record_Sse(arr[0]), + ); + } + + @protected + int dco_decode_i_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as Uint8List; + } + + @protected + MirLogRecord dco_decode_mir_log_record(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 9) + throw Exception('unexpected arr length: expect 9 but see ${arr.length}'); + return MirLogRecord( + levelNumber: dco_decode_u_16(arr[0]), + levelName: dco_decode_String(arr[1]), + message: dco_decode_String(arr[2]), + loggerName: dco_decode_String(arr[3]), + timestamp: dco_decode_String(arr[4]), + rustLog: dco_decode_bool(arr[5]), + modulePath: dco_decode_opt_String(arr[6]), + fileName: dco_decode_opt_String(arr[7]), + lineNumber: dco_decode_opt_box_autoadd_u_32(arr[8]), + ); + } + + @protected + String? dco_decode_opt_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_String(raw); + } + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_u_32(raw); + } + + @protected + int dco_decode_u_16(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + int dco_decode_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + int dco_decode_u_8(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + void dco_decode_unit(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return; + } + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_String(deserializer); + return AnyhowException(inner); + } + + @protected + RustStreamSink sse_decode_StreamSink_mir_log_record_Sse( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + throw UnimplementedError('Unreachable ()'); + } + + @protected + String sse_decode_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_list_prim_u_8_strict(deserializer); + return utf8.decoder.convert(inner); + } + + @protected + bool sse_decode_bool(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8() != 0; + } + + @protected + MirLogRecord sse_decode_box_autoadd_mir_log_record( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_mir_log_record(deserializer)); + } + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_u_32(deserializer)); + } + + @protected + FRBLogger sse_decode_frb_logger(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_streamSink = sse_decode_StreamSink_mir_log_record_Sse(deserializer); + return FRBLogger(streamSink: var_streamSink); + } + + @protected + int sse_decode_i_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getInt32(); + } + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var len_ = sse_decode_i_32(deserializer); + return deserializer.buffer.getUint8List(len_); + } + + @protected + MirLogRecord sse_decode_mir_log_record(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_levelNumber = sse_decode_u_16(deserializer); + var var_levelName = sse_decode_String(deserializer); + var var_message = sse_decode_String(deserializer); + var var_loggerName = sse_decode_String(deserializer); + var var_timestamp = sse_decode_String(deserializer); + var var_rustLog = sse_decode_bool(deserializer); + var var_modulePath = sse_decode_opt_String(deserializer); + var var_fileName = sse_decode_opt_String(deserializer); + var var_lineNumber = sse_decode_opt_box_autoadd_u_32(deserializer); + return MirLogRecord( + levelNumber: var_levelNumber, + levelName: var_levelName, + message: var_message, + loggerName: var_loggerName, + timestamp: var_timestamp, + rustLog: var_rustLog, + modulePath: var_modulePath, + fileName: var_fileName, + lineNumber: var_lineNumber); + } + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_String(deserializer)); + } else { + return null; + } + } + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_u_32(deserializer)); + } else { + return null; + } + } + + @protected + int sse_decode_u_16(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint16(); + } + + @protected + int sse_decode_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint32(); + } + + @protected + int sse_decode_u_8(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8(); + } + + @protected + void sse_decode_unit(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + } + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.message, serializer); + } + + @protected + void sse_encode_StreamSink_mir_log_record_Sse( + RustStreamSink self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String( + self.setupAndSerialize( + codec: SseCodec( + decodeSuccessData: sse_decode_mir_log_record, + decodeErrorData: sse_decode_AnyhowException, + )), + serializer); + } + + @protected + void sse_encode_String(String self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); + } + + @protected + void sse_encode_bool(bool self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self ? 1 : 0); + } + + @protected + void sse_encode_box_autoadd_mir_log_record( + MirLogRecord self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_mir_log_record(self, serializer); + } + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self, serializer); + } + + @protected + void sse_encode_frb_logger(FRBLogger self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_StreamSink_mir_log_record_Sse(self.streamSink, serializer); + } + + @protected + void sse_encode_i_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putInt32(self); + } + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + serializer.buffer.putUint8List(self); + } + + @protected + void sse_encode_mir_log_record(MirLogRecord self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_16(self.levelNumber, serializer); + sse_encode_String(self.levelName, serializer); + sse_encode_String(self.message, serializer); + sse_encode_String(self.loggerName, serializer); + sse_encode_String(self.timestamp, serializer); + sse_encode_bool(self.rustLog, serializer); + sse_encode_opt_String(self.modulePath, serializer); + sse_encode_opt_String(self.fileName, serializer); + sse_encode_opt_box_autoadd_u_32(self.lineNumber, serializer); + } + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_String(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_u_32(self, serializer); + } + } + + @protected + void sse_encode_u_16(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint16(self); + } + + @protected + void sse_encode_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint32(self); + } + + @protected + void sse_encode_u_8(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self); + } + + @protected + void sse_encode_unit(void self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + } +} diff --git a/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart b/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart new file mode 100644 index 00000000000..369982b8e74 --- /dev/null +++ b/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart @@ -0,0 +1,186 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.10.0. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +import 'api/minimal_logging.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'dart:ffi' as ffi; +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart'; + +abstract class RustLibApiImplPlatform extends BaseApiImpl { + RustLibApiImplPlatform({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + RustStreamSink dco_decode_StreamSink_mir_log_record_Sse( + dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + bool dco_decode_bool(dynamic raw); + + @protected + MirLogRecord dco_decode_box_autoadd_mir_log_record(dynamic raw); + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw); + + @protected + FRBLogger dco_decode_frb_logger(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + + @protected + MirLogRecord dco_decode_mir_log_record(dynamic raw); + + @protected + String? dco_decode_opt_String(dynamic raw); + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw); + + @protected + int dco_decode_u_16(dynamic raw); + + @protected + int dco_decode_u_32(dynamic raw); + + @protected + int dco_decode_u_8(dynamic raw); + + @protected + void dco_decode_unit(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + RustStreamSink sse_decode_StreamSink_mir_log_record_Sse( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + MirLogRecord sse_decode_box_autoadd_mir_log_record( + SseDeserializer deserializer); + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + FRBLogger sse_decode_frb_logger(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + MirLogRecord sse_decode_mir_log_record(SseDeserializer deserializer); + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer); + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_u_16(SseDeserializer deserializer); + + @protected + int sse_decode_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_u_8(SseDeserializer deserializer); + + @protected + void sse_decode_unit(SseDeserializer deserializer); + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void sse_encode_StreamSink_mir_log_record_Sse( + RustStreamSink self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_mir_log_record( + MirLogRecord self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_frb_logger(FRBLogger self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer); + + @protected + void sse_encode_mir_log_record(MirLogRecord self, SseSerializer serializer); + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer); + + @protected + void sse_encode_u_16(int self, SseSerializer serializer); + + @protected + void sse_encode_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_u_8(int self, SseSerializer serializer); + + @protected + void sse_encode_unit(void self, SseSerializer serializer); +} + +// Section: wire_class + +class RustLibWire implements BaseWire { + factory RustLibWire.fromExternalLibrary(ExternalLibrary lib) => + RustLibWire(lib.ffiDynamicLibrary); + + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + RustLibWire(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; +} diff --git a/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart b/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart new file mode 100644 index 00000000000..ed3cc9f18d1 --- /dev/null +++ b/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart @@ -0,0 +1,186 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.10.0. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +// Static analysis wrongly picks the IO variant, thus ignore this +// ignore_for_file: argument_type_not_assignable + +import 'api/minimal_logging.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_web.dart'; + +abstract class RustLibApiImplPlatform extends BaseApiImpl { + RustLibApiImplPlatform({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + RustStreamSink dco_decode_StreamSink_mir_log_record_Sse( + dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + bool dco_decode_bool(dynamic raw); + + @protected + MirLogRecord dco_decode_box_autoadd_mir_log_record(dynamic raw); + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw); + + @protected + FRBLogger dco_decode_frb_logger(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + + @protected + MirLogRecord dco_decode_mir_log_record(dynamic raw); + + @protected + String? dco_decode_opt_String(dynamic raw); + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw); + + @protected + int dco_decode_u_16(dynamic raw); + + @protected + int dco_decode_u_32(dynamic raw); + + @protected + int dco_decode_u_8(dynamic raw); + + @protected + void dco_decode_unit(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + RustStreamSink sse_decode_StreamSink_mir_log_record_Sse( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + MirLogRecord sse_decode_box_autoadd_mir_log_record( + SseDeserializer deserializer); + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + FRBLogger sse_decode_frb_logger(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + MirLogRecord sse_decode_mir_log_record(SseDeserializer deserializer); + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer); + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_u_16(SseDeserializer deserializer); + + @protected + int sse_decode_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_u_8(SseDeserializer deserializer); + + @protected + void sse_decode_unit(SseDeserializer deserializer); + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void sse_encode_StreamSink_mir_log_record_Sse( + RustStreamSink self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_mir_log_record( + MirLogRecord self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_frb_logger(FRBLogger self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer); + + @protected + void sse_encode_mir_log_record(MirLogRecord self, SseSerializer serializer); + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer); + + @protected + void sse_encode_u_16(int self, SseSerializer serializer); + + @protected + void sse_encode_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_u_8(int self, SseSerializer serializer); + + @protected + void sse_encode_unit(void self, SseSerializer serializer); +} + +// Section: wire_class + +class RustLibWire implements BaseWire { + RustLibWire.fromExternalLibrary(ExternalLibrary lib); +} + +@JS('wasm_bindgen') +external RustLibWasmModule get wasmModule; + +@JS() +@anonymous +extension type RustLibWasmModule._(JSObject _) implements JSObject {} diff --git a/frb_example/dart_logging/pubspec.lock b/frb_example/dart_logging/pubspec.lock new file mode 100644 index 00000000000..3474e400f3a --- /dev/null +++ b/frb_example/dart_logging/pubspec.lock @@ -0,0 +1,688 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + url: "https://pub.dev" + source: hosted + version: "76.0.0" + _macros: + dependency: transitive + description: dart + source: sdk + version: "0.3.3" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + url: "https://pub.dev" + source: hosted + version: "6.11.0" + archive: + dependency: transitive + description: + name: archive + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" + source: hosted + version: "3.6.1" + args: + dependency: transitive + description: + name: args + sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + url: "https://pub.dev" + source: hosted + version: "2.6.0" + async: + dependency: transitive + description: + name: async + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + url: "https://pub.dev" + source: hosted + version: "2.12.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_cli_annotations: + dependency: transitive + description: + name: build_cli_annotations + sha256: b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172 + url: "https://pub.dev" + source: hosted + version: "2.1.0" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "294a2edaf4814a378725bfe6358210196f5ea37af89ecd81bfa32960113d4948" + url: "https://pub.dev" + source: hosted + version: "4.0.3" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "99d3980049739a985cf9b21f30881f46db3ebc62c5b8d5e60e27440876b1ba1e" + url: "https://pub.dev" + source: hosted + version: "2.4.3" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "74691599a5bc750dc96a6b4bfd48f7d9d66453eab04c7f4063134800d6a5c573" + url: "https://pub.dev" + source: hosted + version: "2.4.14" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" + url: "https://pub.dev" + source: hosted + version: "8.0.0" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: "28a712df2576b63c6c005c465989a348604960c0958d28be5303ba9baa841ac2" + url: "https://pub.dev" + source: hosted + version: "8.9.3" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + cli_config: + dependency: transitive + description: + name: cli_config + sha256: "65c7830649e1f8247660f1b783effb460255d6e2c1ac94eb823cf1f84e59b288" + url: "https://pub.dev" + source: hosted + version: "0.1.2" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + url: "https://pub.dev" + source: hosted + version: "4.10.1" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + coverage: + dependency: transitive + description: + name: coverage + sha256: e3493833ea012784c740e341952298f1cc77f1f01b1bbc3eb4eecf6984fb7f43 + url: "https://pub.dev" + source: hosted + version: "1.11.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" + url: "https://pub.dev" + source: hosted + version: "2.3.7" + ffi: + dependency: transitive + description: + name: ffi + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + ffigen: + dependency: "direct dev" + description: + name: ffigen + sha256: "2119b4fe3aad0db94dc9531b90283c4640a6231070e613c400b426a4da08c704" + url: "https://pub.dev" + source: hosted + version: "16.1.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_rust_bridge: + dependency: "direct main" + description: + path: "../../frb_dart" + relative: true + source: path + version: "2.10.0" + flutter_rust_bridge_utils: + dependency: "direct main" + description: + path: "../../frb_utils" + relative: true + source: path + version: "1.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + sha256: "6022db4c7bfa626841b2a10f34dd1e1b68e8f8f9650db6112dcdeeca45ca793c" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + sha256: c87ff004c8aa6af2d531668b46a4ea379f7191dc6dfa066acd53d506da6e044b + url: "https://pub.dev" + source: hosted + version: "3.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + http: + dependency: transitive + description: + name: http + sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + url: "https://pub.dev" + source: hosted + version: "1.2.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: c50ef5fc083d5b5e12eef489503ba3bf5ccc899e487d691584699b4bdefeea8c + url: "https://pub.dev" + source: hosted + version: "6.9.5" + lints: + dependency: "direct main" + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + macros: + dependency: transitive + description: + name: macros + sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" + url: "https://pub.dev" + source: hosted + version: "0.1.3-main.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_assets_cli: + dependency: transitive + description: + name: native_assets_cli + sha256: "51d1af3ebc2437f5883ed749f1877cb82d6a569b0712dad02c8370e6e4f2b5e3" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + puppeteer: + dependency: transitive + description: + name: puppeteer + sha256: "7a990c68d33882b642214c351f66492d9a738afa4226a098ab70642357337fa2" + url: "https://pub.dev" + source: hosted + version: "3.16.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" + url: "https://pub.dev" + source: hosted + version: "1.3.5" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test: + dependency: "direct dev" + description: + name: test + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" + url: "https://pub.dev" + source: hosted + version: "1.25.15" + test_api: + dependency: transitive + description: + name: test_api + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" + source: hosted + version: "0.7.4" + test_core: + dependency: transitive + description: + name: test_core + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" + url: "https://pub.dev" + source: hosted + version: "0.6.8" + timing: + dependency: transitive + description: + name: timing + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web: + dependency: transitive + description: + name: web + sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" + yaml_edit: + dependency: transitive + description: + name: yaml_edit + sha256: fb38626579fb345ad00e674e2af3a5c9b0cc4b9bfb8fd7f7ff322c7c9e62aef5 + url: "https://pub.dev" + source: hosted + version: "2.2.2" +sdks: + dart: ">=3.6.0 <4.0.0" diff --git a/frb_example/dart_logging/pubspec.yaml b/frb_example/dart_logging/pubspec.yaml new file mode 100644 index 00000000000..66e3891749d --- /dev/null +++ b/frb_example/dart_logging/pubspec.yaml @@ -0,0 +1,20 @@ +name: frb_example_dart_logging +description: flutter rust bridge example +version: 1.0.0 +publish_to: none +environment: + sdk: ">=3.3.0 <4.0.0" +dependencies: + lints: ^5.1.1 + flutter_rust_bridge: + path: ../../frb_dart + flutter_rust_bridge_utils: + path: ../../frb_utils + freezed_annotation: ^3.0.0 + json_annotation: ^4.9.0 +dev_dependencies: + test: ^1.21.4 + freezed: ^3.0.6 + build_runner: ^2.4.4 + ffigen: ^16.1.0 + json_serializable: ^6.9.0 diff --git a/frb_example/dart_logging/rust/Cargo.lock b/frb_example/dart_logging/rust/Cargo.lock new file mode 100644 index 00000000000..1862cbb8fbe --- /dev/null +++ b/frb_example/dart_logging/rust/Cargo.lock @@ -0,0 +1,712 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "allo-isolate" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f67642eb6773fb42a95dd3b348c305ee18dee6642274c6b412d67e985e3befc" +dependencies = [ + "anyhow", + "atomic", + "backtrace", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "build-target" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "dart-sys" +version = "4.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57967e4b200d767d091b961d6ab42cc7d0cc14fe9e052e75d0d3cf9eb732d895" +dependencies = [ + "cc", +] + +[[package]] +name = "delegate-attr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51aac4c99b2e6775164b412ea33ae8441b2fde2dbf05a20bc0052a63d08c475b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "flutter_rust_bridge" +version = "2.10.0" +dependencies = [ + "allo-isolate", + "anyhow", + "build-target", + "bytemuck", + "byteorder", + "chrono", + "console_error_panic_hook", + "dart-sys", + "delegate-attr", + "flutter_rust_bridge_macros", + "futures", + "js-sys", + "lazy_static", + "log", + "portable-atomic", + "threadpool", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "flutter_rust_bridge_macros" +version = "2.10.0" +dependencies = [ + "hex", + "md-5", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frb_example_dart_logging" +version = "0.1.0" +dependencies = [ + "flutter_rust_bridge", + "log", +] + +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "portable-atomic" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" + +[[package]] +name = "proc-macro2" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "tokio" +version = "1.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +dependencies = [ + "backtrace", + "num_cpus", + "pin-project-lite", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] diff --git a/frb_example/dart_logging/rust/Cargo.toml b/frb_example/dart_logging/rust/Cargo.toml new file mode 100644 index 00000000000..52596a57922 --- /dev/null +++ b/frb_example/dart_logging/rust/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "frb_example_dart_logging" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +flutter_rust_bridge = { path = "../../../frb_rust" } +# Optional - can be removed if you do not want logging +log = "^0.4.20" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] } diff --git a/frb_example/dart_logging/rust/src/api/minimal_logging.rs b/frb_example/dart_logging/rust/src/api/minimal_logging.rs new file mode 100644 index 00000000000..0010ec4e30c --- /dev/null +++ b/frb_example/dart_logging/rust/src/api/minimal_logging.rs @@ -0,0 +1,13 @@ +use flutter_rust_bridge::enable_frb_logging; + +enable_frb_logging!(); + +#[frb(init)] +pub fn init_app() { + flutter_rust_bridge::setup_default_user_utils(); +} + +pub fn minimal_adder(a: i32, b: i32) -> i32 { + log::debug!("adding {} and {}", a, b); + a + b +} diff --git a/frb_example/dart_logging/rust/src/api/mod.rs b/frb_example/dart_logging/rust/src/api/mod.rs new file mode 100644 index 00000000000..23e6c541949 --- /dev/null +++ b/frb_example/dart_logging/rust/src/api/mod.rs @@ -0,0 +1 @@ +pub mod minimal_logging; diff --git a/frb_example/dart_logging/rust/src/frb_generated.rs b/frb_example/dart_logging/rust/src/frb_generated.rs new file mode 100644 index 00000000000..9d8bd283851 --- /dev/null +++ b/frb_example/dart_logging/rust/src/frb_generated.rs @@ -0,0 +1,686 @@ +// This file is automatically generated, so please do not edit it. +// @generated by `flutter_rust_bridge`@ 2.10.0. + +#![allow( + non_camel_case_types, + unused, + non_snake_case, + clippy::needless_return, + clippy::redundant_closure_call, + clippy::redundant_closure, + clippy::useless_conversion, + clippy::unit_arg, + clippy::unused_unit, + clippy::double_parens, + clippy::let_and_return, + clippy::too_many_arguments, + clippy::match_single_binding, + clippy::clone_on_copy, + clippy::let_unit_value, + clippy::deref_addrof, + clippy::explicit_auto_deref, + clippy::borrow_deref_ref, + clippy::needless_borrow +)] + +// Section: imports + +use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; +use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; +use flutter_rust_bridge::{Handler, IntoIntoDart}; + +// Section: boilerplate + +flutter_rust_bridge::frb_generated_boilerplate!( + default_stream_sink_codec = SseCodec, + default_rust_opaque = RustOpaqueMoi, + default_rust_auto_opaque = RustAutoOpaqueMoi, +); +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.10.0"; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1044248026; + +// Section: executor + +flutter_rust_bridge::frb_generated_default_handler!(); + +// Section: wire_funcs + +fn wire__crate__api__minimal_logging__frb_logger_new_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "frb_logger_new", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let output_ok = + Result::<_, ()>::Ok(crate::api::minimal_logging::FRBLogger::new())?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__minimal_logging__init_app_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "init_app", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok({ + crate::api::minimal_logging::init_app(); + })?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__minimal_logging__initialize_log_2_dart_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "initialize_log_2_dart", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_log_stream = >::sse_decode(&mut deserializer); + let api_max_log_level = ::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok({ + crate::api::minimal_logging::initialize_log_2_dart( + api_log_stream, + api_max_log_level, + ); + })?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__minimal_logging__log_fn_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "log_fn", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_record = + ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok({ + crate::api::minimal_logging::log_fn(api_record); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__minimal_logging__max_log_level_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "max_log_level", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok(crate::api::minimal_logging::max_log_level())?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__minimal_logging__minimal_adder_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "minimal_adder", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_a = ::sse_decode(&mut deserializer); + let api_b = ::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok( + crate::api::minimal_logging::minimal_adder(api_a, api_b), + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__minimal_logging__root_logger_name_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "root_logger_name", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = + Result::<_, ()>::Ok(crate::api::minimal_logging::root_logger_name())?; + Ok(output_ok) + })()) + }, + ) +} + +// Section: dart2rust + +impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::anyhow::anyhow!("{}", inner); + } +} + +impl SseDecode + for StreamSink< + crate::api::minimal_logging::MirLogRecord, + flutter_rust_bridge::for_generated::SseCodec, + > +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return StreamSink::deserialize(inner); + } +} + +impl SseDecode for String { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = >::sse_decode(deserializer); + return String::from_utf8(inner).unwrap(); + } +} + +impl SseDecode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() != 0 + } +} + +impl SseDecode for crate::api::minimal_logging::FRBLogger { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_streamSink = >::sse_decode(deserializer); + return crate::api::minimal_logging::FRBLogger { + stream_sink: var_streamSink, + }; + } +} + +impl SseDecode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_i32::().unwrap() + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for crate::api::minimal_logging::MirLogRecord { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_levelNumber = ::sse_decode(deserializer); + let mut var_levelName = ::sse_decode(deserializer); + let mut var_message = ::sse_decode(deserializer); + let mut var_loggerName = ::sse_decode(deserializer); + let mut var_timestamp = ::sse_decode(deserializer); + let mut var_rustLog = ::sse_decode(deserializer); + let mut var_modulePath = >::sse_decode(deserializer); + let mut var_fileName = >::sse_decode(deserializer); + let mut var_lineNumber = >::sse_decode(deserializer); + return crate::api::minimal_logging::MirLogRecord { + level_number: var_levelNumber, + level_name: var_levelName, + message: var_message, + logger_name: var_loggerName, + timestamp: var_timestamp, + rust_log: var_rustLog, + module_path: var_modulePath, + file_name: var_fileName, + line_number: var_lineNumber, + }; + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for u16 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u16::().unwrap() + } +} + +impl SseDecode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u32::().unwrap() + } +} + +impl SseDecode for u8 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() + } +} + +impl SseDecode for () { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} +} + +fn pde_ffi_dispatcher_primary_impl( + func_id: i32, + port: flutter_rust_bridge::for_generated::MessagePort, + ptr: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len: i32, + data_len: i32, +) { + // Codec=Pde (Serialization + dispatch), see doc to use other codecs + match func_id { + 1 => wire__crate__api__minimal_logging__frb_logger_new_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 2 => wire__crate__api__minimal_logging__init_app_impl(port, ptr, rust_vec_len, data_len), + 3 => wire__crate__api__minimal_logging__initialize_log_2_dart_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 6 => { + wire__crate__api__minimal_logging__minimal_adder_impl(port, ptr, rust_vec_len, data_len) + } + _ => unreachable!(), + } +} + +fn pde_ffi_dispatcher_sync_impl( + func_id: i32, + ptr: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len: i32, + data_len: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + // Codec=Pde (Serialization + dispatch), see doc to use other codecs + match func_id { + 4 => wire__crate__api__minimal_logging__log_fn_impl(ptr, rust_vec_len, data_len), + 5 => wire__crate__api__minimal_logging__max_log_level_impl(ptr, rust_vec_len, data_len), + 7 => wire__crate__api__minimal_logging__root_logger_name_impl(ptr, rust_vec_len, data_len), + _ => unreachable!(), + } +} + +// Section: rust2dart + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::minimal_logging::FRBLogger { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [self.stream_sink.into_into_dart().into_dart()].into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::minimal_logging::FRBLogger +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::minimal_logging::FRBLogger +{ + fn into_into_dart(self) -> crate::api::minimal_logging::FRBLogger { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::minimal_logging::MirLogRecord { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.level_number.into_into_dart().into_dart(), + self.level_name.into_into_dart().into_dart(), + self.message.into_into_dart().into_dart(), + self.logger_name.into_into_dart().into_dart(), + self.timestamp.into_into_dart().into_dart(), + self.rust_log.into_into_dart().into_dart(), + self.module_path.into_into_dart().into_dart(), + self.file_name.into_into_dart().into_dart(), + self.line_number.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::minimal_logging::MirLogRecord +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::minimal_logging::MirLogRecord +{ + fn into_into_dart(self) -> crate::api::minimal_logging::MirLogRecord { + self + } +} + +impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(format!("{:?}", self), serializer); + } +} + +impl SseEncode + for StreamSink< + crate::api::minimal_logging::MirLogRecord, + flutter_rust_bridge::for_generated::SseCodec, + > +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + unimplemented!("") + } +} + +impl SseEncode for String { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.into_bytes(), serializer); + } +} + +impl SseEncode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self as _).unwrap(); + } +} + +impl SseEncode for crate::api::minimal_logging::FRBLogger { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.stream_sink, serializer); + } +} + +impl SseEncode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_i32::(self).unwrap(); + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for crate::api::minimal_logging::MirLogRecord { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.level_number, serializer); + ::sse_encode(self.level_name, serializer); + ::sse_encode(self.message, serializer); + ::sse_encode(self.logger_name, serializer); + ::sse_encode(self.timestamp, serializer); + ::sse_encode(self.rust_log, serializer); + >::sse_encode(self.module_path, serializer); + >::sse_encode(self.file_name, serializer); + >::sse_encode(self.line_number, serializer); + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for u16 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u16::(self).unwrap(); + } +} + +impl SseEncode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u32::(self).unwrap(); + } +} + +impl SseEncode for u8 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self).unwrap(); + } +} + +impl SseEncode for () { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} +} + +#[cfg(not(target_family = "wasm"))] +mod io { + // This file is automatically generated, so please do not edit it. + // @generated by `flutter_rust_bridge`@ 2.10.0. + + // Section: imports + + use super::*; + use flutter_rust_bridge::for_generated::byteorder::{ + NativeEndian, ReadBytesExt, WriteBytesExt, + }; + use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; + use flutter_rust_bridge::{Handler, IntoIntoDart}; + + // Section: boilerplate + + flutter_rust_bridge::frb_generated_boilerplate_io!(); +} +#[cfg(not(target_family = "wasm"))] +pub use io::*; + +/// cbindgen:ignore +#[cfg(target_family = "wasm")] +mod web { + // This file is automatically generated, so please do not edit it. + // @generated by `flutter_rust_bridge`@ 2.10.0. + + // Section: imports + + use super::*; + use flutter_rust_bridge::for_generated::byteorder::{ + NativeEndian, ReadBytesExt, WriteBytesExt, + }; + use flutter_rust_bridge::for_generated::wasm_bindgen; + use flutter_rust_bridge::for_generated::wasm_bindgen::prelude::*; + use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; + use flutter_rust_bridge::{Handler, IntoIntoDart}; + + // Section: boilerplate + + flutter_rust_bridge::frb_generated_boilerplate_web!(); +} +#[cfg(target_family = "wasm")] +pub use web::*; diff --git a/frb_example/dart_logging/rust/src/lib.rs b/frb_example/dart_logging/rust/src/lib.rs new file mode 100644 index 00000000000..a57332801d0 --- /dev/null +++ b/frb_example/dart_logging/rust/src/lib.rs @@ -0,0 +1,8 @@ +// AUTO INJECTED BY flutter_rust_bridge. +// The following lines may not be accurate; change them according to your needs. +mod frb_generated; +// this export is needed for logging +pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// END of AUTO INJECTED code + +pub mod api; diff --git a/frb_example/dart_logging/test/dart_valgrind_test_entrypoint.dart b/frb_example/dart_logging/test/dart_valgrind_test_entrypoint.dart new file mode 100644 index 00000000000..09c05d7a2d3 --- /dev/null +++ b/frb_example/dart_logging/test/dart_valgrind_test_entrypoint.dart @@ -0,0 +1,5 @@ +import 'logging_test.dart' as minimal_test; + +Future main() async { + await minimal_test.main(); +} diff --git a/frb_example/dart_logging/test/dart_web_test_entrypoint.dart b/frb_example/dart_logging/test/dart_web_test_entrypoint.dart new file mode 100644 index 00000000000..fc428d81da5 --- /dev/null +++ b/frb_example/dart_logging/test/dart_web_test_entrypoint.dart @@ -0,0 +1,9 @@ +import 'package:flutter_rust_bridge_utils/flutter_rust_bridge_utils_web.dart'; + +import 'logging_test.dart' as minimal_test; + +Future main() async { + await dartWebTestEntrypoint(() async { + await minimal_test.main(); + }); +} diff --git a/frb_example/dart_logging/test/empty_entrypoint.dart b/frb_example/dart_logging/test/empty_entrypoint.dart new file mode 100644 index 00000000000..ab73b3a234a --- /dev/null +++ b/frb_example/dart_logging/test/empty_entrypoint.dart @@ -0,0 +1 @@ +void main() {} diff --git a/frb_example/dart_logging/test/logging_test.dart b/frb_example/dart_logging/test/logging_test.dart new file mode 100644 index 00000000000..4a49db0671c --- /dev/null +++ b/frb_example/dart_logging/test/logging_test.dart @@ -0,0 +1,19 @@ +import 'dart:async'; + +import 'package:frb_example_dart_logging/src/rust/api/minimal_logging.dart'; +import 'package:frb_example_dart_logging/src/rust/frb_generated.dart'; +import 'package:test/test.dart'; + +Future main() async { + print('Action: Init rust (before)'); + await RustLib.init(); + print('Action: Init rust (after)'); + + print('Action: Configure tests (before)'); + test('dart call minimalAdder', () async { + print('Action: Call rust (before)'); + expect(await minimalAdder(a: 100, b: 200), 300); + print('Action: Call rust (after)'); + }); + print('Action: Configure tests (end)'); +} diff --git a/frb_example/dart_logging/web/.gitignore b/frb_example/dart_logging/web/.gitignore new file mode 100644 index 00000000000..ab4772b91e7 --- /dev/null +++ b/frb_example/dart_logging/web/.gitignore @@ -0,0 +1 @@ +main.dart.js* \ No newline at end of file diff --git a/frb_example/dart_logging/web/experiment_call_wasm_from_js.html b/frb_example/dart_logging/web/experiment_call_wasm_from_js.html new file mode 100644 index 00000000000..6552f8e1db0 --- /dev/null +++ b/frb_example/dart_logging/web/experiment_call_wasm_from_js.html @@ -0,0 +1,30 @@ + + + +Experiment (not directly related to flutter_rust_bridge): +Call Rust WASM from JavaScript. + +NOTE: Please open this html using *different* origin from where the JS/WASM is hosted to test CORS + policy + + + + + \ No newline at end of file diff --git a/tools/frb_internal/lib/src/makefile_dart/consts.dart b/tools/frb_internal/lib/src/makefile_dart/consts.dart index d114c6be0f6..6b3eef85de0 100644 --- a/tools/frb_internal/lib/src/makefile_dart/consts.dart +++ b/tools/frb_internal/lib/src/makefile_dart/consts.dart @@ -5,6 +5,7 @@ import 'package:flutter_rust_bridge_internal/src/utils/makefile_dart_infra.dart' const kRustPackagesAllowWeb = [ 'frb_rust', 'frb_example/dart_minimal/rust', + 'frb_example/dart_logging/rust', 'frb_example/pure_dart/rust', 'frb_example/pure_dart_pde/rust', 'frb_example/dart_build_rs/rust', @@ -36,6 +37,7 @@ const kDartExampleIntegratePackages = [ const kDartExamplePackages = [ 'frb_example/dart_minimal', + 'frb_example/dart_logging', 'frb_example/pure_dart', 'frb_example/pure_dart_pde', 'frb_example/dart_build_rs', @@ -65,6 +67,7 @@ const kDartModeOfPackage = { 'frb_utils': DartMode.dart, 'tools/frb_internal': DartMode.dart, 'frb_example/dart_minimal': DartMode.dart, + 'frb_example/dart_logging': DartMode.dart, 'frb_example/pure_dart': DartMode.dart, 'frb_example/pure_dart_pde': DartMode.dart, 'frb_example/dart_build_rs': DartMode.dart, diff --git a/website/docs/guides/contributing/overview.md b/website/docs/guides/contributing/overview.md index 87b9597a568..a95c6c39bdc 100644 --- a/website/docs/guides/contributing/overview.md +++ b/website/docs/guides/contributing/overview.md @@ -43,6 +43,7 @@ There is no need to read it word by word, since it serves as a reference to find - `frb_example`: Examples. - `pure_dart`: A pure-Dart example + contains most tests. - `dart_minimal`: Minimalist pure-Dart example. Suitable as a playground. + - `dart_logging`: Minimalist pure-Dart example with logging. - `flutter_via_create` / `flutter_via_integrate`: Examples automatically generated via `flutter_rust_bridge_codegen create/integrate`. - `deliberate_bad`: Deliberately buggy code to check sanitizers catch them. - `frb_dart` (`flutter_rust_bridge` Dart package): Support library for Dart - to be imported by users. @@ -117,7 +118,7 @@ If you want to know more details, here is a table. (Code are adapted to ease understanding, thus it does not reflect actual details.) | Name | Sample Location | Sample code | Source | -|-----------|------------------------------------------------------------------------|-------------------------------------------------------------------|---------------| +| --------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------- | | User call | `lib/main.dart` | `print(f('Hello'));` | User provided | | Dart API | `lib/src/rust/api/minimal.dart`,
`lib/src/rust/frb_generated.dart` | `void f(String arg) => wire_f(codec.encode(arg))` | Generated | | Dart Wire | `lib/src/rust/frb_generated.dart` | `void wire_f(char* ptr, int len); /* extern function */` | Generated | From dec6047129ad06dc501f26a01fd7c17eff8e0904 Mon Sep 17 00:00:00 2001 From: patmuk Date: Tue, 1 Jul 2025 07:30:45 +0200 Subject: [PATCH 15/26] fixes codacy issues --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb710c26d70..68f56f01948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ * Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/guides/miscellaneous/whats-new for what's changed in V2. * Overhaul of the logging implementation, from an opinionated approach to a configurable one. Please consult the [documentation](https://fzyzcjy.github.io/flutter_rust_bridge/guides/logging) for more information. If you implemented logging yourself you might have to migrate your changes. - ## 2.10.0 * Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/guides/miscellaneous/whats-new for what's changed in V2. From 4c39d58918f668827406e2c68f5efec608a7d9b2 Mon Sep 17 00:00:00 2001 From: patmuk Date: Wed, 2 Jul 2025 09:29:27 +0200 Subject: [PATCH 16/26] clarifies which setup steps are needed when --- website/docs/guides/how-to/logging.md | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/website/docs/guides/how-to/logging.md b/website/docs/guides/how-to/logging.md index cfe7e15ba42..57f724eba20 100644 --- a/website/docs/guides/how-to/logging.md +++ b/website/docs/guides/how-to/logging.md @@ -8,15 +8,25 @@ Under the hood (and in a nutshell) our implementation uses the [Rust 'log' crate Log messages are sent via a FRB's Stream implementation from Rust to Dart. ## Setup -### 1. add the logging dependency -First you need to add a dependency on the logging crate in your Cargo.toml file with `cargo add log` or by putting `log = "^0.4.20"` in your Cargo.toml file under the `[dependencies]` section. -If you start with a new project (`flutter_rust_bridge_codegen create` instead of `flutter_rust_bridge_codegen generate`) this dependency is already added for you. +### 1. activate logging +Add the macro call `enable_frb_logging!();` in a **Rust** file that is part of your `rust_input` of your `flutter_rust_bridge.yaml` configuration, at any place outside of an item (e.g. function or struct). +You need to make it available via `use flutter_rust_bridge::enable_frb_logging;`. + +It needs to be there so the code generation is picking it up and generates the needed bridge code for connecting Rust and Dart for logging. + +If you start a new project and use default values this is all you need to do! +Otherwise read the next steps: + +### 2. add the logging dependency (not needed for new projects) +For a new project (if you prompted `flutter_rust_bridge_codegen create` instead of `flutter_rust_bridge_codegen generate`) the dependency is already added. +Otherwise you need to add a dependency on the logging crate yourself, in your Cargo.toml file with `cargo add log` or by putting `log = "^0.4.20"` in your Cargo.toml file under the `[dependencies]` section. -### 2. expose the generated StreamSink -Next, you need to expose a generated `StreamSink` so the logging code can find it. -If you have not disabled automatically configuring your `lib.rs` in your `flutter_rust_bridge.yaml` (with `add_mod_to_lib: false`) these lines are added for you. +### 3. expose the generated StreamSink (if automatic lib.rs configuration is disabled) +Only if you disabled automatically configuring of your `lib.rs` in your `flutter_rust_bridge.yaml` (with `add_mod_to_lib: false`) you need to do this step. -Otherwise, enter +You need to expose a generated `StreamSink` so the logging code can find it. + +Enter ``` // this export is needed for logging pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; @@ -25,14 +35,10 @@ into your project's `lib.rs`. Replace `frb_generated` in `crate::frb_generated::StreamSink` with the module path where you configured the generated files to go to, i.e. the value you set for `rust_output` in the `flutter_rust_bridge.yaml` configuration file. If you did not set this option `crate::frb_generated` is the correct default, no need to change this. -### 3. activate logging -Finally, add the macro call `enable_frb_logging!();` in a **Rust** file that is part of your `rust_input` of your `flutter_rust_bridge.yaml` configuration, at any place outside of an item (e.g. function or struct). -You need to make it available via `use flutter_rust_bridge::enable_frb_logging;`. -It needs to be there so the code generation is picking it up and generates the needed bridge code for connecting Rust and Dart for logging. - -### 4. customize the log function +### (optional) 4. customize the log function Per default any log output is written to `stdout`, via `println!` in Rust. + You can provide your own log function, as described further down in `utilize a logging framework`. Note that this is needed, if you are developing a _Flutter_ application, as `stdout` is not shown. From 4013de801cfaaaae6d2b1376abbe97fb0e72741b Mon Sep 17 00:00:00 2001 From: patmuk Date: Thu, 3 Jul 2025 10:56:31 +0200 Subject: [PATCH 17/26] improves lib.rs code injection to be more automagical --- .../codegen/polisher/add_mod_to_lib.rs | 373 +++++++++++------- frb_example/dart_logging/rust/src/lib.rs | 5 +- frb_rust/src/lib.rs | 4 +- frb_rust/src/misc/logging.rs | 41 +- 4 files changed, 254 insertions(+), 169 deletions(-) diff --git a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs index 3c372217dbc..9a6187e93a4 100644 --- a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs +++ b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs @@ -2,7 +2,7 @@ use anyhow::*; use log::{debug, info, warn}; use pathdiff::diff_paths; use std::fs; -use std::path::Path; +use std::path::{Component, Path}; // the function signature is not covered while the whole body is covered - looks like a bug in coverage tool // frb-coverage:ignore-start @@ -29,19 +29,14 @@ fn auto_add_mod_to_lib_core(rust_crate_dir: &Path, rust_output_path: &Path) -> R ) })?; - let mod_name = rust_output_path_relative_to_src_folder - .file_stem() - .context("No file_stem")? - .to_str() - .context("Not a UTF-8 path")? - .to_string() - .replace('/', "::"); - let path_lib_rs = path_src_folder.join("lib.rs"); let raw_content_lib_rs = fs::read_to_string(&path_lib_rs)?; let lib_rs_content_normalized = raw_content_lib_rs.replace("\r\n", "\n"); - let final_content = process_lib_rs_content(&lib_rs_content_normalized, &mod_name); + let final_content = process_lib_rs_content( + &lib_rs_content_normalized, + &rust_output_path_relative_to_src_folder, + )?; // --- Write back only if content actually changed from the original normalized state, ignoring white spaces --- if final_content.replace("/n", "") != lib_rs_content_normalized.replace("/n", "") { @@ -53,15 +48,62 @@ fn auto_add_mod_to_lib_core(rust_crate_dir: &Path, rust_output_path: &Path) -> R Ok(()) } -fn process_lib_rs_content(initial_content: &str, mod_name: &str) -> String { +fn process_lib_rs_content(initial_content: &str, relative_path: &Path) -> Result { const CODE_INJECT_BLOCK_MARKER_START: &str = "// AUTO INJECTED BY flutter_rust_bridge."; const CODE_INJECT_BLOCK_MARKER_END: &str = "// END of AUTO INJECTED code"; + let relative_path = &relative_path.with_extension(""); + + let (mod_name, path) = if relative_path + .parent() + // test is path is just "" + .is_some_and(|parents| parents.parent().is_some()) + { + // Path has a parent, meaning it's not just a filename + // mod_name: first component of the original relative_path (e.g., "bridge" from "bridge/gen/frb_generated.rs") + let mod_name_first_component = relative_path + .components() + .next() // Get the first component of the *original* relative_path + .and_then(|component| match component { + Component::Normal(s) => s.to_str(), + _ => { + unreachable!("The path should be relative!") + } + }) + .context("First component of path is not valid UTF-8 or could not be extracted")? + .to_string(); + + // path: the full parent path, without the filename, with "::" separators + let path_string_with_colons = relative_path + .to_str() + .context("the path is not valid UTF-8")? + .replace(std::path::MAIN_SEPARATOR, "::"); + + Ok((mod_name_first_component, Some(path_string_with_colons))) + } else { + // Path has no parent, meaning it's a filename only (e.g., "frb_generated.rs") + // mod_name: the file_stem (filename without extension) + Ok(( + relative_path + .to_str() + .context("File stem is not valid UTF-8")? + .to_string(), + None, + )) + }?; + let code_to_inject = format!( "// The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ - // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;" + mod {mod_name};{}", + path.map_or_else( + || "".to_string(), + |path| { + format!( + "\n\ + use crate::{path};" + ) + } + ) ); let code_to_inject_full_block = format!( @@ -70,8 +112,8 @@ fn process_lib_rs_content(initial_content: &str, mod_name: &str) -> String { // TODO remove this lines after a migration period // remove FRB's per-v2.10.0 injectedd code - let legacy_frb_injected_code = format!("mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */"); - + let legacy_frb_injected_code = format!("mod {}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + , relative_path.to_str().context("File stem is not valid UTF-8")?); let mut in_injected_block = false; let mut new_code_injected = false; let mut pre_code_injection_text = String::new(); @@ -146,7 +188,7 @@ fn process_lib_rs_content(initial_content: &str, mod_name: &str) -> String { }; // have only one neline in the very end output = format!("{}\n", output.trim_end_matches('\n')); - output + Ok(output) } fn _inject_code(pre_code_injection_text: &str, code_to_inject: &str) -> String { @@ -165,19 +207,40 @@ mod tests { use super::*; // Helper to get the expected new injected block for tests - fn get_expected_new_block(mod_name: &str) -> String { + fn get_expected_new_block_filename_only(mod_name: &Path) -> String { format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ - // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ - // END of AUTO INJECTED code\n\n", + mod {};\n\ + // END of AUTO INJECTED code\n", + mod_name.with_extension("").to_str().unwrap() + ) + } + fn get_expected_new_block_with_path(mod_name: &Path, path: &Path) -> String { + format!( + "// AUTO INJECTED BY flutter_rust_bridge.\n\ + // The following lines may not be accurate; change them according to your needs.\n\ + mod {};\n\ + use crate::{};\n\ + // END of AUTO INJECTED code\n", + mod_name.to_str().unwrap(), + path.to_str() + .unwrap() + .replace(std::path::MAIN_SEPARATOR, "::") ) } - fn get_expected_full_file(mod_name: &str) -> String { - format!("{}pub mod api;\n", get_expected_new_block(mod_name)) + fn get_expected_full_file_filename_only(mod_name: &Path) -> String { + format!( + "{}\npub mod api;\n", + get_expected_new_block_filename_only(mod_name) + ) + } + fn get_expected_full_file_with_path(mod_name: &Path, path: &Path) -> String { + format!( + "{}\npub mod api;\n", + get_expected_new_block_with_path(mod_name, path) + ) } // --- Test Cases --- @@ -185,138 +248,170 @@ mod tests { #[test] fn test_inject_into_empty_lib_rs() { let initial_content = ""; - let mod_name = "frb_generated"; - let mut result_content = process_lib_rs_content(initial_content, mod_name); - // makes assert easier - result_content.push('\n'); - assert_eq!(result_content, get_expected_new_block(mod_name)); + let path = Path::new("frb_generated.rs"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_new_block_filename_only(path)); } #[test] fn test_inject_into_existing_lib_rs_without_newline_at_end() { let initial_content = "pub mod api;"; // No trailing newline - let mod_name = "frb_generated"; - let result_content = process_lib_rs_content(initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let path = Path::new("frb_generated"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); + } + + #[test] + fn test_inject_into_existing_lib_rs_with_path() { + let initial_content = "pub mod api;"; // No trailing newline + let path = Path::new("bridge/gen/frb_generated.rs"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!( + result_content, + get_expected_full_file_with_path( + Path::new("bridge"), + path.with_extension("").as_path() + ) + ); + } + #[test] + fn test_inject_into_existing_lib_rs_with_one_path() { + let initial_content = "pub mod api;"; // No trailing newline + let path = Path::new("gen/frb_generated.rs"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!( + result_content, + get_expected_full_file_with_path(Path::new("gen"), path.with_extension("").as_path()) + ); } #[test] fn test_inject_into_existing_lib_rs_with_newline_at_end() { let initial_content = "pub mod api;\n"; // With trailing newline - let mod_name = "frb_generated"; - let result_content = process_lib_rs_content(initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let path = Path::new("frb_generated"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_inject_into_existing_lib_rs_with_multiple_newlines_at_end() { let initial_content = "pub mod api;\n\n\n"; // With trailing newline - let mod_name = "frb_generated"; - let result_content = process_lib_rs_content(initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let path = Path::new("frb_generated"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_inject_into_existing_lib_rs_with_multiple_newlines() { let initial_content = "\n\n\npub mod api;\n\n\n"; // With trailing newline - let mod_name = "frb_generated"; - let result_content = process_lib_rs_content(initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let path = Path::new("frb_generated"); + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_no_change_if_already_up_to_date_new_format() { - let mod_name = "frb_generated"; - let initial_content = get_expected_full_file(mod_name); - let result_content = process_lib_rs_content(&initial_content, mod_name); + let path = Path::new("frb_generated"); + let initial_content = get_expected_full_file_filename_only(path); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); assert_eq!(result_content, initial_content); // Should remain unchanged } #[test] fn test_leave_at_top() { - let mod_name = "frb_generated"; - let result_content = process_lib_rs_content(&get_expected_full_file(mod_name), mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); // Should remain unchanged + let path = Path::new("frb_generated"); + let result_content = + process_lib_rs_content(&get_expected_full_file_filename_only(path), path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); // Should remain unchanged } #[test] fn test_replace_old_format_with_new_format() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); let old_injected_line = format!( - "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + "mod {}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + , path.to_str().unwrap() ); let initial_content = format!( "pub mod api;\n{old_injected_line}\nother code;" // Old format embedded ); - let result_content = process_lib_rs_content(&initial_content, mod_name); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); let expected_code = format!( - "{}pub mod api;\nother code;\n", // Old format removed, new prepended, remaining code at end - get_expected_new_block(mod_name) + "{}\npub mod api;\nother code;\n", // Old format removed, new prepended, remaining code at end + get_expected_new_block_filename_only(path) ); assert_eq!(result_content, expected_code); } #[test] fn test_replace_only_old_format_file() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); let old_injected_line = format!( - "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + "mod {}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + , path.to_str().unwrap() ); let initial_content = format!("{old_injected_line}\n"); // File contains only the old format - let mut result_content = process_lib_rs_content(&initial_content, mod_name); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); // Should be replaced by only the new block - // push one more \n to make comparission easier - result_content.push('\n'); - assert_eq!(result_content, get_expected_new_block(mod_name)); + assert_eq!(result_content, get_expected_new_block_filename_only(path)); // Should remain unchanged } #[test] fn test_idempotent_after_replacement() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); let old_injected_line = format!( - "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + "mod {}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + , path.to_str().unwrap() ); let initial_content = format!("pub mod api;\n{old_injected_line}\n"); - let content_after_first_run = process_lib_rs_content(&initial_content, mod_name); // First run: replace old with new - let content_after_second_run = process_lib_rs_content(&content_after_first_run, mod_name); // Second run: should not change + let content_after_first_run = process_lib_rs_content(&initial_content, path).unwrap(); // First run: replace old with new + let content_after_second_run = + process_lib_rs_content(&content_after_first_run, path).unwrap(); // Second run: should not change assert_eq!(content_after_first_run, content_after_second_run); - // assert_eq!(content_after_second_run, get_expected_full_file(mod_name)); + assert_eq!( + content_after_second_run, + get_expected_full_file_filename_only(path) + ); } #[test] fn test_multiple_old_formats() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let old_injected_line = format!( - "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */"); + "mod {}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + , path.to_str().unwrap() + ); let initial_content = format!( "{old_injected_line}\npub mod api;\n{old_injected_line}\n" // Multiple old formats ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_multpipe_code_markers() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ pub mod api;\n // AUTO INJECTED BY flutter_rust_bridge.\n\ The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] @@ -324,17 +419,18 @@ mod tests { expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code end marker '// END of AUTO INJECTED code'.\nThis is the content:\n" )] fn test_incomplete_code_markers_only_start() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ pub mod api;\n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] @@ -342,15 +438,16 @@ mod tests { expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code start marker '// AUTO INJECTED BY flutter_rust_bridge.'.\nThis is the content:\n" )] fn test_incomplete_code_markers_only_end() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( - "mod {mod_name};\n\ + "mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ pub mod api;\n" ); - let _ = process_lib_rs_content(&initial_content, mod_name); + let _ = process_lib_rs_content(&initial_content, path).unwrap(); } #[test] @@ -358,82 +455,83 @@ mod tests { expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code end marker '// END of AUTO INJECTED code'.\nThis is the content:\n" )] fn test_multiple_start_code_markers_without_end() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ pub mod api;\n // AUTO INJECTED BY flutter_rust_bridge.\n\ The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n" + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] #[should_panic( expected = "\nCould not generate code for lib.rs, as the content is wrong (missing injected code start marker '// AUTO INJECTED BY flutter_rust_bridge.'.\nThis is the content:\n" )] fn test_multiple_end_code_markers_without_start() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( - "mod {mod_name};\n\ + "mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ pub mod api;\n - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_new_format_old_content() { - let mod_name = "frb_generated"; + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ + mod {path_str};\n\ // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::{path_str}::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ pub mod api;\n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_replace_old_generated_content_with_new() { - let mod_name = "frb_generated"; - let initial_content = format!( - "// AUTO INJECTED BY flutter_rust_bridge.\n\ + let path = Path::new("frb_generated"); + let initial_content = "// AUTO INJECTED BY flutter_rust_bridge.\n\ This are outdated lines, to be replaced!\n\ And another old line.\n\ If these are still inside, the test fails!\n\ // END of AUTO INJECTED code\n\ - pub mod api;\n" - ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - assert_eq!(result_content, get_expected_full_file(mod_name)); + pub mod api;\n"; + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + assert_eq!(result_content, get_expected_full_file_filename_only(path)); } #[test] fn test_mixed_formats_and_other_content_replace_at_place() { - let mod_name = "frb_generated"; - let old_injected_line = format!( - "mod {mod_name}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" - ); - let existing_new_block = get_expected_new_block(mod_name); + let path = Path::new("frb_generated"); + let old_injected_line = format!( "mod {}; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */" + , path.to_str().unwrap() + ); + let existing_new_block = get_expected_new_block_filename_only(path); let initial_content = format!( "// Some header comments\n\ @@ -445,11 +543,11 @@ mod tests { {old_injected_line}\n\ // Some footer comments\n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); let expected_code = format!( "// Some header comments\n\ - {existing_new_block}\ + {existing_new_block}\n\ pub mod feature_a;\n\n\ pub mod feature_b;\n\n\ // Some footer comments\n" @@ -459,14 +557,12 @@ mod tests { #[test] fn test_only_empty_lines_differ() { - let mod_name = "frb_generated"; - + let path = Path::new("frb_generated"); + let path_str = path.to_str().unwrap(); let initial_content = format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};\n\ - // this export is needed for logging\n\ - pub use crate::{mod_name}::StreamSink as __FrbStreamSinkForLogging;\n\ + mod {path_str};\n\ // END of AUTO INJECTED code\n\ \n\ // AUTO-GENERATED FROM frb_example/pure_dart, DO NOT EDIT\n\ @@ -476,7 +572,7 @@ mod tests { pub fn function_at_lib_rs()\n\ \n" ); - let result_content = process_lib_rs_content(&initial_content, mod_name); + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); assert_eq!( result_content.replace("\n", ""), @@ -485,57 +581,46 @@ mod tests { } #[test] fn test_keep_directive_on_top() { - let mod_name = "frb_generated"; - + let path = Path::new("frb_generated"); let initial_content = " #![allow(clippy::new_without_default)] pub mod app; " .to_string(); - let result_content = process_lib_rs_content(&initial_content, mod_name); - let expected_code = format!( - "#![allow(clippy::new_without_default)]\n\ + let result_content = process_lib_rs_content(&initial_content, path).unwrap(); + let expected_code = "#![allow(clippy::new_without_default)]\n\ \n\ // AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ mod frb_generated;\n\ - // this export is needed for logging\n\ - pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ \n\ - pub mod app;\n" - ); + pub mod app;\n"; assert_eq!(result_content, expected_code); } #[test] fn test_remove_top_newline() { - let mod_name = "frb_generated"; - let initial_content = format!( - "\n\ + let path = Path::new("frb_generated"); + let initial_content = "\n\ #![allow(clippy::new_without_default)]\n\ \n\ // AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ mod frb_generated;\n\ // this export is needed for logging\n\ - pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ + use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ \n\ - pub mod app;\n" - ); - let result_content = process_lib_rs_content(&initial_content, mod_name); - let expected_code = format!( - "#![allow(clippy::new_without_default)]\n\ + pub mod app;\n"; + let result_content = process_lib_rs_content(initial_content, path).unwrap(); + let expected_code = "#![allow(clippy::new_without_default)]\n\ \n\ // AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ mod frb_generated;\n\ - // this export is needed for logging\n\ - pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ \n\ - pub mod app;\n" - ); + pub mod app;\n"; assert_eq!(result_content, expected_code); } } diff --git a/frb_example/dart_logging/rust/src/lib.rs b/frb_example/dart_logging/rust/src/lib.rs index a57332801d0..87c9ab70949 100644 --- a/frb_example/dart_logging/rust/src/lib.rs +++ b/frb_example/dart_logging/rust/src/lib.rs @@ -1,8 +1,7 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. -mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +mod bridge; +use crate::bridge::frb_generated; // END of AUTO INJECTED code pub mod api; diff --git a/frb_rust/src/lib.rs b/frb_rust/src/lib.rs index 74867e57355..684b9fb34dd 100644 --- a/frb_rust/src/lib.rs +++ b/frb_rust/src/lib.rs @@ -42,9 +42,9 @@ pub use crate::misc::dart_dynamic::DartDynamic; pub use crate::misc::into_into_dart::IntoIntoDart; // needed for testing the logging feature // in a consuming project's lib.rs this would be -// pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; +// pub use crate::path_as_specified_by_rust_output::frb_generated; #[cfg(test)] -use crate::misc::logging::test::MockStreamSink as __FrbStreamSinkForLogging; +use crate::misc::logging::test::mock_frb_generated as frb_generated; pub use crate::misc::panic_backtrace::{CatchUnwindWithBacktrace, PanicBacktrace}; #[cfg(feature = "user-utils")] pub use crate::misc::user_utils::setup_default_user_utils; diff --git a/frb_rust/src/misc/logging.rs b/frb_rust/src/misc/logging.rs index be5a0a2a6f6..eb973f06dae 100644 --- a/frb_rust/src/misc/logging.rs +++ b/frb_rust/src/misc/logging.rs @@ -59,7 +59,7 @@ macro_rules! enable_frb_logging { } use flutter_rust_bridge::frb; - use crate::__FrbStreamSinkForLogging as StreamSink; + use crate::frb_generated::StreamSink; use $crate::for_generated::chrono; #[flutter_rust_bridge::frb(dart_code = " @@ -274,27 +274,28 @@ macro_rules! enable_frb_logging { pub(crate) mod test { use flutter_rust_bridge_macros as flutter_rust_bridge; use log::{Level, Log, Metadata, Record}; - use std::sync::{Arc, Mutex}; - // A simple mock for StreamSink for testing - #[derive(Debug, Clone)] - pub struct MockStreamSink { - pub sent_records: Arc>>, - } + pub mod mock_frb_generated { + use std::sync::{Arc, Mutex}; + // A simple mock for StreamSink for testing + #[derive(Debug, Clone)] + pub struct StreamSink { + pub sent_records: Arc>>, + } - impl MockStreamSink { - pub fn new() -> Self { - Self { - sent_records: Arc::new(Mutex::new(Vec::new())), + impl StreamSink { + pub fn new() -> Self { + Self { + sent_records: Arc::new(Mutex::new(Vec::new())), + } } - } - pub fn add(&self, item: T) -> Result<(), crate::Rust2DartSendError> { - self.sent_records.lock().unwrap().push(item); - Ok(()) + pub fn add(&self, item: T) -> Result<(), crate::Rust2DartSendError> { + self.sent_records.lock().unwrap().push(item); + Ok(()) + } } } - #[test] fn test_default_logger_name() { enable_frb_logging!(); @@ -348,7 +349,7 @@ pub(crate) mod test { // For testing, we might need to "reset" the global logger state if possible, // or ensure tests run in isolation (e.g., with `cargo test -- --test-threads=1`). // For simplicity here, we'll try to catch a potential panic if already set. - let stream_sink = MockStreamSink::new(); + let stream_sink = StreamSink::new(); let max_log_level = to_u16(log::LevelFilter::Info); let result = std::panic::catch_unwind(|| { @@ -376,7 +377,7 @@ pub(crate) mod test { #[test] fn test_frb_logger_enabled() { enable_frb_logging!(); - let stream_sink = MockStreamSink::new(); + let stream_sink = StreamSink::new(); let logger = FRBLogger { stream_sink }; // Temporarily set max log level for this test @@ -410,7 +411,7 @@ pub(crate) mod test { fn test_frb_logger_log() { enable_frb_logging!(); let logger = FRBLogger { - stream_sink: MockStreamSink::new(), + stream_sink: StreamSink::new(), }; // Temporarily set max log level for this test @@ -457,7 +458,7 @@ pub(crate) mod test { #[test] fn test_frb_logger_flush() { enable_frb_logging!(); - let stream_sink = MockStreamSink::new(); + let stream_sink = StreamSink::new(); let logger = FRBLogger { stream_sink }; // This method does nothing, so we just call it to ensure it doesn't panic. logger.flush(); From 1f80b3660be7dc0c9210dc9cc141e3ad80b4c8d0 Mon Sep 17 00:00:00 2001 From: patmuk Date: Thu, 3 Jul 2025 10:56:51 +0200 Subject: [PATCH 18/26] changes the example to have a specified rust_output --- frb_example/dart_logging/flutter_rust_bridge.yaml | 2 ++ frb_example/dart_logging/rust/src/{ => bridge}/frb_generated.rs | 0 frb_example/dart_logging/rust/src/bridge/mod.rs | 1 + 3 files changed, 3 insertions(+) rename frb_example/dart_logging/rust/src/{ => bridge}/frb_generated.rs (100%) create mode 100644 frb_example/dart_logging/rust/src/bridge/mod.rs diff --git a/frb_example/dart_logging/flutter_rust_bridge.yaml b/frb_example/dart_logging/flutter_rust_bridge.yaml index f98e28e477f..d72e727b403 100644 --- a/frb_example/dart_logging/flutter_rust_bridge.yaml +++ b/frb_example/dart_logging/flutter_rust_bridge.yaml @@ -1,5 +1,7 @@ # See `pure_dart` example for comments on the configs rust_input: rust/src/api/**/*.rs +# rust_output: 'rust/src/bridge/gen/frb_generated.rs' +rust_output: 'rust/src/bridge/frb_generated.rs' dart_output: lib/src/rust c_output: frb_generated.h dump_all: true diff --git a/frb_example/dart_logging/rust/src/frb_generated.rs b/frb_example/dart_logging/rust/src/bridge/frb_generated.rs similarity index 100% rename from frb_example/dart_logging/rust/src/frb_generated.rs rename to frb_example/dart_logging/rust/src/bridge/frb_generated.rs diff --git a/frb_example/dart_logging/rust/src/bridge/mod.rs b/frb_example/dart_logging/rust/src/bridge/mod.rs new file mode 100644 index 00000000000..56ecf8eed3e --- /dev/null +++ b/frb_example/dart_logging/rust/src/bridge/mod.rs @@ -0,0 +1 @@ +pub mod frb_generated; From 55d06ac02da91779b6b6e2957ab975744e90a82d Mon Sep 17 00:00:00 2001 From: patmuk Date: Thu, 3 Jul 2025 11:45:58 +0200 Subject: [PATCH 19/26] adapts generates lib.rs files --- .../shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs | 2 -- frb_example/dart_build_rs/rust/src/lib.rs | 2 -- frb_example/dart_minimal/rust/src/lib.rs | 2 -- frb_example/deliberate_bad/rust/src/lib.rs | 2 -- frb_example/flutter_package/rust/src/lib.rs | 2 -- frb_example/flutter_via_create/rust/src/lib.rs | 2 -- frb_example/flutter_via_integrate/rust/src/lib.rs | 2 -- frb_example/gallery/rust/src/frb_generated.rs | 2 +- frb_example/gallery/rust/src/lib.rs | 2 -- frb_example/integrate_third_party/rust/src/lib.rs | 2 -- frb_example/pure_dart/rust/src/lib.rs | 2 -- frb_example/pure_dart_pde/rust/src/lib.rs | 2 -- frb_example/rust_ui_counter/src/lib.rs | 2 -- frb_example/rust_ui_todo_list/src/lib.rs | 2 -- 14 files changed, 1 insertion(+), 27 deletions(-) diff --git a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs +++ b/frb_codegen/assets/integration_template/shared/REPLACE_ME_RUST_CRATE_DIR/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/dart_build_rs/rust/src/lib.rs b/frb_example/dart_build_rs/rust/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_example/dart_build_rs/rust/src/lib.rs +++ b/frb_example/dart_build_rs/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/dart_minimal/rust/src/lib.rs b/frb_example/dart_minimal/rust/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_example/dart_minimal/rust/src/lib.rs +++ b/frb_example/dart_minimal/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/deliberate_bad/rust/src/lib.rs b/frb_example/deliberate_bad/rust/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_example/deliberate_bad/rust/src/lib.rs +++ b/frb_example/deliberate_bad/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/flutter_package/rust/src/lib.rs b/frb_example/flutter_package/rust/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_example/flutter_package/rust/src/lib.rs +++ b/frb_example/flutter_package/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/flutter_via_create/rust/src/lib.rs b/frb_example/flutter_via_create/rust/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_example/flutter_via_create/rust/src/lib.rs +++ b/frb_example/flutter_via_create/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/flutter_via_integrate/rust/src/lib.rs b/frb_example/flutter_via_integrate/rust/src/lib.rs index a57332801d0..598f05181c4 100644 --- a/frb_example/flutter_via_integrate/rust/src/lib.rs +++ b/frb_example/flutter_via_integrate/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/gallery/rust/src/frb_generated.rs b/frb_example/gallery/rust/src/frb_generated.rs index c214b617a58..12803976e3a 100644 --- a/frb_example/gallery/rust/src/frb_generated.rs +++ b/frb_example/gallery/rust/src/frb_generated.rs @@ -238,7 +238,7 @@ impl flutter_rust_bridge::IntoIntoDart impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - ::sse_encode(format!("{self:?}"), serializer); + ::sse_encode(format!("{:?}", self), serializer); } } diff --git a/frb_example/gallery/rust/src/lib.rs b/frb_example/gallery/rust/src/lib.rs index 88b0d574266..739902678c6 100644 --- a/frb_example/gallery/rust/src/lib.rs +++ b/frb_example/gallery/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/integrate_third_party/rust/src/lib.rs b/frb_example/integrate_third_party/rust/src/lib.rs index a2d97f069b7..322b9611499 100644 --- a/frb_example/integrate_third_party/rust/src/lib.rs +++ b/frb_example/integrate_third_party/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/pure_dart/rust/src/lib.rs b/frb_example/pure_dart/rust/src/lib.rs index c8257427fe4..bb7ca527f22 100644 --- a/frb_example/pure_dart/rust/src/lib.rs +++ b/frb_example/pure_dart/rust/src/lib.rs @@ -1,8 +1,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/pure_dart_pde/rust/src/lib.rs b/frb_example/pure_dart_pde/rust/src/lib.rs index 8a28dc583ff..2f696b60092 100644 --- a/frb_example/pure_dart_pde/rust/src/lib.rs +++ b/frb_example/pure_dart_pde/rust/src/lib.rs @@ -3,8 +3,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod api; diff --git a/frb_example/rust_ui_counter/src/lib.rs b/frb_example/rust_ui_counter/src/lib.rs index 1d1ed931785..e3630c0eb0a 100644 --- a/frb_example/rust_ui_counter/src/lib.rs +++ b/frb_example/rust_ui_counter/src/lib.rs @@ -3,8 +3,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod app; diff --git a/frb_example/rust_ui_todo_list/src/lib.rs b/frb_example/rust_ui_todo_list/src/lib.rs index 1d1ed931785..e3630c0eb0a 100644 --- a/frb_example/rust_ui_todo_list/src/lib.rs +++ b/frb_example/rust_ui_todo_list/src/lib.rs @@ -3,8 +3,6 @@ // AUTO INJECTED BY flutter_rust_bridge. // The following lines may not be accurate; change them according to your needs. mod frb_generated; -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; // END of AUTO INJECTED code pub mod app; From a558443c7ca65871640afd3899f576718f599297 Mon Sep 17 00:00:00 2001 From: patmuk Date: Thu, 3 Jul 2025 14:51:48 +0200 Subject: [PATCH 20/26] makes initLogger optional --- frb_dart/lib/src/utils/frb_logger.dart | 6 ++++-- frb_example/dart_logging/lib/main.dart | 9 ++++++--- .../lib/src/rust/api/minimal_logging.dart | 12 +++++++++--- .../dart_logging/rust/src/api/minimal_logging.rs | 2 +- frb_rust/src/misc/logging.rs | 12 +++++++++--- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/frb_dart/lib/src/utils/frb_logger.dart b/frb_dart/lib/src/utils/frb_logger.dart index 5313b2db624..afa9969ebbc 100644 --- a/frb_dart/lib/src/utils/frb_logger.dart +++ b/frb_dart/lib/src/utils/frb_logger.dart @@ -200,7 +200,8 @@ class FRBDartLogger { void Function({required dynamic record})? customLogFunction, }) { if (_singleton != null) { - throw Exception('Called FRBLogger.initLogger() twice!'); + throw Exception( + 'Called FRBLogger.initLogger() twice or after FRBLogger.getLogger()!'); } // Assign the singleton directly using a private constructor. @@ -244,7 +245,8 @@ class FRBDartLogger { /// It returns `FRBDartLogger` as `frb_logger.dart` doesn't know the concrete type. static FRBDartLogger getLogger([String? name]) { if (_singleton == null) { - throw Exception("You have to call FRBLogger.initLogger() first!"); + throw Exception( + "This exception should not happen - please file a bug ticket!"); } var loggerName = name ?? _currentLoggerName; Logger(loggerName); diff --git a/frb_example/dart_logging/lib/main.dart b/frb_example/dart_logging/lib/main.dart index 70513b31fde..a4ffc5d72a0 100644 --- a/frb_example/dart_logging/lib/main.dart +++ b/frb_example/dart_logging/lib/main.dart @@ -1,12 +1,15 @@ -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'dart:io'; + import 'package:frb_example_dart_logging/src/rust/api/minimal_logging.dart'; import 'package:frb_example_dart_logging/src/rust/frb_generated.dart'; -final LOGGER = FRBLogger.initLogger(maxLogLevel: LogLevel.trace); +// final LOGGER = FRBLogger.initLogger(maxLogLevel: LogLevel.trace); +final LOGGER = FRBLogger.getLogger(); // If you are developing a binary program, you may want to put it in `bin/something.dart` Future main() async { await RustLib.init(); - LOGGER.trace( + LOGGER.info( 'Call Rust and get: 100+200 = ${await minimalAdder(a: 100, b: 200)}'); + exit(0); } diff --git a/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart b/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart index cec3018046d..b519db1054e 100644 --- a/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart +++ b/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart @@ -42,7 +42,7 @@ class FRBLogger { RustLib.instance.api.crateApiMinimalLoggingFrbLoggerNew(); static FRBDartLogger initLogger( - {String name = 'FRBLogger', + {String? name = 'FRBLogger', LogLevel maxLogLevel = LogLevel.info, Function({required MirLogRecord record}) customLogFunction = logFn}) { //initialize the rust side @@ -70,7 +70,7 @@ class FRBLogger { return FRBDartLogger.initAndGetSingleton( streamSink: stream, - name: name, + name: name ?? 'FRBLogger', logFn: wrappedLogFn, fromDartLogRecord: wrappedFromDartLogRecord, maxLogLevel: maxLogLevel, @@ -79,7 +79,13 @@ class FRBLogger { } static FRBDartLogger getLogger([String? name]) { - return FRBDartLogger.getLogger(name); + FRBDartLogger logger; + try { + logger = FRBDartLogger.getLogger(name); + } catch (e) { + logger = FRBLogger.initLogger(name: name); + } + return logger; } @override diff --git a/frb_example/dart_logging/rust/src/api/minimal_logging.rs b/frb_example/dart_logging/rust/src/api/minimal_logging.rs index 0010ec4e30c..4dca1aaefbf 100644 --- a/frb_example/dart_logging/rust/src/api/minimal_logging.rs +++ b/frb_example/dart_logging/rust/src/api/minimal_logging.rs @@ -8,6 +8,6 @@ pub fn init_app() { } pub fn minimal_adder(a: i32, b: i32) -> i32 { - log::debug!("adding {} and {}", a, b); + log::info!("adding {} and {}", a, b); a + b } diff --git a/frb_rust/src/misc/logging.rs b/frb_rust/src/misc/logging.rs index eb973f06dae..ba118cffdc4 100644 --- a/frb_rust/src/misc/logging.rs +++ b/frb_rust/src/misc/logging.rs @@ -66,7 +66,7 @@ macro_rules! enable_frb_logging { import 'package:logging/logging.dart'; static FRBDartLogger initLogger( - {String name = 'FRBLogger', + {String? name = 'FRBLogger', LogLevel maxLogLevel = LogLevel.info, Function({required MirLogRecord record}) customLogFunction = logFn}) { //initialize the rust side @@ -94,7 +94,7 @@ macro_rules! enable_frb_logging { return FRBDartLogger.initAndGetSingleton( streamSink: stream, - name: name, + name: name ?? 'FRBLogger', logFn: wrappedLogFn, fromDartLogRecord: wrappedFromDartLogRecord, maxLogLevel: maxLogLevel, @@ -103,7 +103,13 @@ macro_rules! enable_frb_logging { } static FRBDartLogger getLogger([String? name]) { - return FRBDartLogger.getLogger(name); + FRBDartLogger logger; + try { + logger = FRBDartLogger.getLogger(name); + } catch (e) { + logger = FRBLogger.initLogger(name: name); + } + return logger; } ")] pub struct FRBLogger { From fd8a0115451667c4bdd96c7d323ef85765c474a7 Mon Sep 17 00:00:00 2001 From: patmuk Date: Thu, 3 Jul 2025 15:36:30 +0200 Subject: [PATCH 21/26] updates the documentation --- website/docs/guides/how-to/logging.md | 60 +++++++++++---------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/website/docs/guides/how-to/logging.md b/website/docs/guides/how-to/logging.md index 57f724eba20..0ebf39e995a 100644 --- a/website/docs/guides/how-to/logging.md +++ b/website/docs/guides/how-to/logging.md @@ -21,20 +21,17 @@ Otherwise read the next steps: For a new project (if you prompted `flutter_rust_bridge_codegen create` instead of `flutter_rust_bridge_codegen generate`) the dependency is already added. Otherwise you need to add a dependency on the logging crate yourself, in your Cargo.toml file with `cargo add log` or by putting `log = "^0.4.20"` in your Cargo.toml file under the `[dependencies]` section. -### 3. expose the generated StreamSink (if automatic lib.rs configuration is disabled) -Only if you disabled automatically configuring of your `lib.rs` in your `flutter_rust_bridge.yaml` (with `add_mod_to_lib: false`) you need to do this step. - -You need to expose a generated `StreamSink` so the logging code can find it. - -Enter -``` -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; -``` -into your project's `lib.rs`. - -Replace `frb_generated` in `crate::frb_generated::StreamSink` with the module path where you configured the generated files to go to, i.e. the value you set for `rust_output` in the `flutter_rust_bridge.yaml` configuration file. If you did not set this option `crate::frb_generated` is the correct default, no need to change this. - +### 3. expose the generated code in lib.rs (only if automatic lib.rs configuration is disabled) +Most probably you can skip this step - your generated code might already be available. +Depending on your customization you might need to do this step. + +- I did not set `add_mod_to_lib: false` + - If you did not disabled automatically configuring of your `lib.rs` in your `flutter_rust_bridge.yaml` (with `add_mod_to_lib: false`) you don't have to do anything for this step and can go to the nest one. +- I did set `add_mod_to_lib: false` and + - I did not set `rust_output` to a custom location + - If your lib.rs file contains `mod frb_generated;` you don't need any other changes and can skipp to the next step. + - I set `rust_output` to a custom location + - Additional to setting up the mod sturcture correctly so that `frb_generated` is available to the rust compiler (which you surely did already), you have to import it so the logging code can use it. Thus, add the statement `use crate::rust::output::folder::frb_generated`, where `rust::output::folder` is the path you specified in `rust_output`. ### (optional) 4. customize the log function Per default any log output is written to `stdout`, via `println!` in Rust. @@ -51,16 +48,8 @@ You can issue log statements in Rust and Dart by following the usual way done in In **Rust** simply call `log::info!()` (or any of the [log crate's log levels](https://docs.rs/log/latest/log/enum.Level.html)). -In **Dart** you first need to initialise logging with a call to `final LOGGER = FRBLogger.initLogger()`. -If you do this call more than once an Exception is thrown. -This not only sets up logging for the Rust side, it returns a logger you can use to record log statements as well. - -Doing this in `main.dart`, preferably as a global variable `final LOGGER = FRBLogger.initLogger();`, is recommended, so no Rust log statement is executed before this setup. - -To get the logger handle after the initialization you can call `final LOGGER = FRBLogger.getLogger()`. -This is in turn calling `FRBDartLogger.getLogger()`, which you can call directly instead (they are effectively the same). - -In both calls (`.initLogger()` and `.getLogger()`) you can provide a `LoggerName` (which defaults to "FRBLogger"). +In **Dart** just follow the usual way of working with a logging framework: Get the logger singleto with a call to `final LOGGER = FRBLogger.getLogger()` or `final LOGGER = FRBDartLogger.getLogger()`. +The latter calls the former, so you can use either. To issue a log statement, you then call `LOGGER.info('Hello world');` (or other log levels) on that instance. Note that in **Rust** code you use the [log crate's log levels](https://docs.rs/log/latest/log/enum.Level.html), while in **Dart** code you use a mixture of those and [Dart's logging package equivalents](https://pub.dev/documentation/logging/latest/logging/Level-class.html). @@ -83,14 +72,18 @@ There are three parameters that can be customized: 3. `customLogFunction` The function to use for logging (default: `println!`). You can override the defaults by passing arguments to `enable_frb_logging!();` in your Rust code or `FRBLogger.initLogger()` in your Dart code. +You have the choice in which language you like to do this customization, the result is the same. The parameter names of these are the same for both languages. Be aware that while the order doesn't matter in Dart, it matters in the Rust macro call! Avoid setting these parameters on both sides (Rust and Dart) at the same time. -The implementation will take the values set in Dart if `FRBLogger.initLogger()` is called before any subsequent `FRBLogger.getLogger();` call - otherwise, it takes the values set with `enable_frb_logging!();`. +The implementation will take the values set in Dart if `FRBLogger.initLogger()` is called before any log statement done via Rust - otherwise, it takes the values set with `enable_frb_logging!();`. +Thus do this preferable in `main.dart`, as a global variable `final LOGGER = FRBLogger.initLogger();`, so no Rust log statement is executed before this setup. -When you customize the logging in your Dart code with `FRBLogger.initLogger()`, the call returns an instance of a logger, which you can use. -There is no need for a call to `FRBLogger.getLogger();` (with the same name parameter), as this will return the same instance. +The call to `FRBLogger.initLogger()` returns the logger singleton, so that a subsequent call to `FRBLogger.getLogger()` is not needed. +Be aware that you need to call `initLogger()` before any call to `getLogger()`, and that you can call `initLogger()` only once - otherwise an exception will be thrown (so we ensure a proper setup). + +In both calls (`.initLogger()` and `.getLogger()`) you can provide a `LoggerName` (which defaults to "FRBLogger"). ### Change the root logger name @@ -368,23 +361,18 @@ Unrecognized literal: `(/*ERROR*/)` ``` the code in the `enable_frb_logging!();` macro has not been expanded correctly - most probably you forgot to add the dependency to `log = "^0.4.20"` in your Cargo.toml file or you passed a syntactically incorrect custom function to the macro. -### no `__FrbStreamSinkForLogging` in the root +### no `StreamSink` in the root If you get the error message ``` enable_frb_logging!(); - | ^^^^^^^^^^^^^^^^^^^^^ no `__FrbStreamSinkForLogging` in the root + | ^^^^^^^^^^^^^^^^^^^^^ no `StreamSink` in the root | = note: this error originates in the macro `enable_frb_logging` (in Nightly builds, run with -Z macro-backtrace for more info) ``` the `StreamSink` is probably not re-exported in your project's `lib.rs`. -Add -``` -// this export is needed for logging -pub use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging; -``` -to do so. -Notice that `frb_generated` has to point to the module path where you configured the generated code to be written to, which defaults to `crate::frb_generated`. + +See Step 3 of "setup" how to make the generated code available correctly. ### no log output in the emulator! If you are testing a Flutter application in an emulator the output to `stdout` is not visible. From ed549ee83001ebfab3ad4560c31452e301dc982c Mon Sep 17 00:00:00 2001 From: patmuk Date: Sun, 6 Jul 2025 20:23:33 +0200 Subject: [PATCH 22/26] CI upgrades windows-2019 to windows-2025 --- .github/workflows/ci.yaml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5bdc6ad8e1a..b9fd44b7e2e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -175,7 +175,7 @@ jobs: fail-fast: false matrix: image: - - windows-2019 + - windows-2025 - macos-13 - ubuntu-24.04 package: @@ -191,11 +191,11 @@ jobs: - frb_example--rust_ui_counter--ui - frb_example--rust_ui_todo_list--ui exclude: - - { image: windows-2019, package: frb_example--deliberate_bad } + - { image: windows-2025, package: frb_example--deliberate_bad } - { image: macos-13, package: frb_example--deliberate_bad } - - { image: windows-2019, package: frb_example--integrate_third_party } + - { image: windows-2025, package: frb_example--integrate_third_party } - { image: macos-13, package: frb_example--integrate_third_party } - - { image: windows-2019, package: frb_example--flutter_via_integrate } + - { image: windows-2025, package: frb_example--flutter_via_integrate } - { image: macos-13, package: frb_example--flutter_via_integrate } steps: @@ -236,7 +236,7 @@ jobs: matrix: image: - macos-13 - - windows-2019 + - windows-2025 - ubuntu-24.04 package: - frb_example--flutter_via_create @@ -312,7 +312,7 @@ jobs: fail-fast: false matrix: image: - - windows-2019 + - windows-2025 - macos-13 - ubuntu-24.04 @@ -388,7 +388,7 @@ jobs: fail-fast: false matrix: info: - - image: windows-2019 + - image: windows-2025 target: windows - image: macos-13 target: macos @@ -435,7 +435,7 @@ jobs: fail-fast: false matrix: image: - - windows-2019 + - windows-2025 # need macos-"13" because https://github.com/fzyzcjy/flutter_rust_bridge/issues/1225 - macos-13 - ubuntu-latest @@ -472,7 +472,7 @@ jobs: fail-fast: false matrix: image: - - windows-2019 + - windows-2025 # need macos-"13" because https://github.com/fzyzcjy/flutter_rust_bridge/issues/1225 - macos-13 - ubuntu-latest @@ -519,7 +519,7 @@ jobs: # run on various platforms - image: macos-13 version: '' - - image: windows-2019 + - image: windows-2025 version: '' - image: ubuntu-latest version: '' @@ -567,7 +567,7 @@ jobs: fail-fast: false matrix: image: - - windows-2019 + - windows-2025 - macos-13 - ubuntu-24.04 package: @@ -580,11 +580,11 @@ jobs: - frb_example--dart_build_rs - frb_example--deliberate_bad exclude: - - { image: windows-2019, package: frb_utils } + - { image: windows-2025, package: frb_utils } - { image: macos-13, package: frb_utils } - - { image: windows-2019, package: tools--frb_internal } + - { image: windows-2025, package: tools--frb_internal } - { image: macos-13, package: tools--frb_internal } - - { image: windows-2019, package: frb_example--deliberate_bad } + - { image: windows-2025, package: frb_example--deliberate_bad } - { image: macos-13, package: frb_example--deliberate_bad } steps: @@ -860,7 +860,7 @@ jobs: fail-fast: false matrix: info: - - image: windows-2019 + - image: windows-2025 platform: windows package: frb_example--flutter_via_create # need macos-"13" because https://github.com/fzyzcjy/flutter_rust_bridge/issues/1225 @@ -871,7 +871,7 @@ jobs: platform: linux package: frb_example--flutter_via_create - - image: windows-2019 + - image: windows-2025 platform: windows package: frb_example--flutter_package--example - image: macos-13 @@ -881,7 +881,7 @@ jobs: platform: linux package: frb_example--flutter_package--example - - image: windows-2019 + - image: windows-2025 platform: windows package: frb_example--rust_ui_counter--ui - image: macos-13 @@ -891,7 +891,7 @@ jobs: platform: linux package: frb_example--rust_ui_counter--ui - - image: windows-2019 + - image: windows-2025 platform: windows package: frb_example--rust_ui_todo_list--ui - image: macos-13 From 628b56c230ba9a0250e6e6e1b74350cae396888c Mon Sep 17 00:00:00 2001 From: patmuk Date: Mon, 7 Jul 2025 08:40:23 +0200 Subject: [PATCH 23/26] upgrades FRB to 2.11.1 in the dart_logging example --- frb_example/dart_logging/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frb_example/dart_logging/pubspec.lock b/frb_example/dart_logging/pubspec.lock index 3474e400f3a..e5ce3e2e2c4 100644 --- a/frb_example/dart_logging/pubspec.lock +++ b/frb_example/dart_logging/pubspec.lock @@ -236,7 +236,7 @@ packages: path: "../../frb_dart" relative: true source: path - version: "2.10.0" + version: "2.11.1" flutter_rust_bridge_utils: dependency: "direct main" description: From 589e12d9d4e7218fc81f1eefc0b056e796180a3e Mon Sep 17 00:00:00 2001 From: patmuk Date: Mon, 7 Jul 2025 14:43:44 +0200 Subject: [PATCH 24/26] upgrades build artefacts --- .../lib/src/rust/api/minimal_logging.dart | 2 +- .../lib/src/rust/frb_generated.dart | 4 +- .../lib/src/rust/frb_generated.io.dart | 2 +- .../lib/src/rust/frb_generated.web.dart | 2 +- frb_example/dart_logging/rust/Cargo.lock | 311 ++++++++++++------ .../rust/src/bridge/frb_generated.rs | 8 +- 6 files changed, 222 insertions(+), 107 deletions(-) diff --git a/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart b/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart index b519db1054e..082ef6b74a0 100644 --- a/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart +++ b/frb_example/dart_logging/lib/src/rust/api/minimal_logging.dart @@ -1,5 +1,5 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.10.0. +// @generated by `flutter_rust_bridge`@ 2.11.1. // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import diff --git a/frb_example/dart_logging/lib/src/rust/frb_generated.dart b/frb_example/dart_logging/lib/src/rust/frb_generated.dart index 46eba3f38ed..5f505baa621 100644 --- a/frb_example/dart_logging/lib/src/rust/frb_generated.dart +++ b/frb_example/dart_logging/lib/src/rust/frb_generated.dart @@ -1,5 +1,5 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.10.0. +// @generated by `flutter_rust_bridge`@ 2.11.1. // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field @@ -67,7 +67,7 @@ class RustLib extends BaseEntrypoint { kDefaultExternalLibraryLoaderConfig; @override - String get codegenVersion => '2.10.0'; + String get codegenVersion => '2.11.1'; @override int get rustContentHash => 1044248026; diff --git a/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart b/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart index 369982b8e74..359aa12ee09 100644 --- a/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart +++ b/frb_example/dart_logging/lib/src/rust/frb_generated.io.dart @@ -1,5 +1,5 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.10.0. +// @generated by `flutter_rust_bridge`@ 2.11.1. // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field diff --git a/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart b/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart index ed3cc9f18d1..b7cc2dc090b 100644 --- a/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart +++ b/frb_example/dart_logging/lib/src/rust/frb_generated.web.dart @@ -1,5 +1,5 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.10.0. +// @generated by `flutter_rust_bridge`@ 2.11.1. // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field diff --git a/frb_example/dart_logging/rust/Cargo.lock b/frb_example/dart_logging/rust/Cargo.lock index 1862cbb8fbe..becb57f0425 100644 --- a/frb_example/dart_logging/rust/Cargo.lock +++ b/frb_example/dart_logging/rust/Cargo.lock @@ -4,24 +4,24 @@ version = 4 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "allo-isolate" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f67642eb6773fb42a95dd3b348c305ee18dee6642274c6b412d67e985e3befc" +checksum = "449e356a4864c017286dbbec0e12767ea07efba29e3b7d984194c2a7ff3c4550" dependencies = [ "anyhow", "atomic", @@ -45,9 +45,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "atomic" @@ -57,25 +57,31 @@ checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + [[package]] name = "block-buffer" version = "0.10.4" @@ -93,15 +99,15 @@ checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" [[package]] name = "byteorder" @@ -111,18 +117,18 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.83" +version = "1.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" dependencies = [ - "libc", + "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "chrono" @@ -196,7 +202,7 @@ dependencies = [ [[package]] name = "flutter_rust_bridge" -version = "2.10.0" +version = "2.11.1" dependencies = [ "allo-isolate", "anyhow", @@ -222,7 +228,7 @@ dependencies = [ [[package]] name = "flutter_rust_bridge_macros" -version = "2.10.0" +version = "2.11.1" dependencies = [ "hex", "md-5", @@ -241,9 +247,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -256,9 +262,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -266,15 +272,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -283,15 +289,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -300,21 +306,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -340,15 +346,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" @@ -380,32 +386,44 @@ dependencies = [ "cc", ] +[[package]] +name = "io-uring" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" +dependencies = [ + "bitflags", + "cfg-if", + "libc", +] + [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "log" -version = "0.4.20" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "md-5" @@ -419,17 +437,28 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ - "adler", + "libc", + "wasi", + "windows-sys", ] [[package]] @@ -443,9 +472,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ "hermit-abi", "libc", @@ -453,24 +482,24 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -480,54 +509,57 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" -version = "1.8.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "slab" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -545,32 +577,41 @@ dependencies = [ [[package]] name = "tokio" -version = "1.34.0" +version = "1.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" dependencies = [ "backtrace", - "num_cpus", + "io-uring", + "libc", + "mio", "pin-project-lite", + "slab", ] [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" @@ -600,12 +641,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] @@ -644,9 +686,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -710,3 +752,76 @@ checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ "windows-link", ] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/frb_example/dart_logging/rust/src/bridge/frb_generated.rs b/frb_example/dart_logging/rust/src/bridge/frb_generated.rs index 9d8bd283851..78020ec3551 100644 --- a/frb_example/dart_logging/rust/src/bridge/frb_generated.rs +++ b/frb_example/dart_logging/rust/src/bridge/frb_generated.rs @@ -1,5 +1,5 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.10.0. +// @generated by `flutter_rust_bridge`@ 2.11.1. #![allow( non_camel_case_types, @@ -36,7 +36,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_opaque = RustOpaqueMoi, default_rust_auto_opaque = RustAutoOpaqueMoi, ); -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.10.0"; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.11.1"; pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1044248026; // Section: executor @@ -643,7 +643,7 @@ impl SseEncode for () { #[cfg(not(target_family = "wasm"))] mod io { // This file is automatically generated, so please do not edit it. - // @generated by `flutter_rust_bridge`@ 2.10.0. + // @generated by `flutter_rust_bridge`@ 2.11.1. // Section: imports @@ -665,7 +665,7 @@ pub use io::*; #[cfg(target_family = "wasm")] mod web { // This file is automatically generated, so please do not edit it. - // @generated by `flutter_rust_bridge`@ 2.10.0. + // @generated by `flutter_rust_bridge`@ 2.11.1. // Section: imports From 723a93068a90dca445f92f41a401feb911e48a6c Mon Sep 17 00:00:00 2001 From: patmuk Date: Tue, 2 Sep 2025 09:38:39 +0200 Subject: [PATCH 25/26] changes visibility of the generated mod --- .../src/library/codegen/polisher/add_mod_to_lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs index 9a6187e93a4..dc6e8df98df 100644 --- a/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs +++ b/frb_codegen/src/library/codegen/polisher/add_mod_to_lib.rs @@ -94,7 +94,7 @@ fn process_lib_rs_content(initial_content: &str, relative_path: &Path) -> Result let code_to_inject = format!( "// The following lines may not be accurate; change them according to your needs.\n\ - mod {mod_name};{}", + pub mod {mod_name};{}", path.map_or_else( || "".to_string(), |path| { @@ -211,7 +211,7 @@ mod tests { format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod {};\n\ + pub mod {};\n\ // END of AUTO INJECTED code\n", mod_name.with_extension("").to_str().unwrap() ) @@ -220,7 +220,7 @@ mod tests { format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod {};\n\ + pub mod {};\n\ use crate::{};\n\ // END of AUTO INJECTED code\n", mod_name.to_str().unwrap(), @@ -562,7 +562,7 @@ mod tests { let initial_content = format!( "// AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod {path_str};\n\ + pub mod {path_str};\n\ // END of AUTO INJECTED code\n\ \n\ // AUTO-GENERATED FROM frb_example/pure_dart, DO NOT EDIT\n\ @@ -592,7 +592,7 @@ mod tests { \n\ // AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod frb_generated;\n\ + pub mod frb_generated;\n\ // END of AUTO INJECTED code\n\ \n\ pub mod app;\n"; @@ -606,7 +606,7 @@ mod tests { \n\ // AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod frb_generated;\n\ + pub mod frb_generated;\n\ // this export is needed for logging\n\ use crate::frb_generated::StreamSink as __FrbStreamSinkForLogging;\n\ // END of AUTO INJECTED code\n\ @@ -617,7 +617,7 @@ mod tests { \n\ // AUTO INJECTED BY flutter_rust_bridge.\n\ // The following lines may not be accurate; change them according to your needs.\n\ - mod frb_generated;\n\ + pub mod frb_generated;\n\ // END of AUTO INJECTED code\n\ \n\ pub mod app;\n"; From 7d5986e6bbd6139c98cfc8df69c661e0ee6a9121 Mon Sep 17 00:00:00 2001 From: patmuk Date: Tue, 6 Jan 2026 09:33:03 +0100 Subject: [PATCH 26/26] fixes an error when platform.environment is unsupported (like on web) --- frb_dart/lib/src/utils/frb_logger.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frb_dart/lib/src/utils/frb_logger.dart b/frb_dart/lib/src/utils/frb_logger.dart index afa9969ebbc..b1a071da2fe 100644 --- a/frb_dart/lib/src/utils/frb_logger.dart +++ b/frb_dart/lib/src/utils/frb_logger.dart @@ -217,7 +217,12 @@ class FRBDartLogger { Logger(name); _currentLoggerName = name; - String? envLogLevel = Platform.environment['LOG_LEVEL']; + String? envLogLevel; + try { + envLogLevel = Platform.environment['LOG_LEVEL']; + } on UnsupportedError { + envLogLevel = null; + } if (envLogLevel != null) { print( 'Taking log level from env: $envLogLevel instead of the one given by code: $maxLogLevel');