fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use &[u8] as params, build error

gtmickey opened this issue · comments

Describe the bug

write an simple method on rust to expose to dart

#[flutter_rust_bridge::frb(sync)]
pub fn from_seed_unchecked(seed: &[u8]) -> String { return PrivateKey::from_seed_unchecked(seed).to_string(); }

then run: flutter_rust_bridge_codegen generate
then: flutter run

error shows

SEVERE: error[E0599]: the method `rust_auto_opaque_decode_ref` exists for struct `RustOpaqueBase<RwLock<[u8]>, MoiArc<RwLock<[u8]>>>`, but its trait bounds were not satisfied
SEVERE:   --> src/frb_generated.rs:68:41
SEVERE:    |
SEVERE: 68 |                 let api_seed = api_seed.rust_auto_opaque_decode_ref();
SEVERE:    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `RustOpaqueBase<RwLock<[u8]>, MoiArc<RwLock<[u8]>>>` due to unsatisfied trait bounds

Steps to reproduce

a simple method to gen

#[flutter_rust_bridge::frb(sync)]
pub fn from_seed_unchecked(seed: &[u8]) -> String { return PrivateKey::from_seed_unchecked(seed).to_string(); }

Logs

SEVERE: error[E0599]: the method `rust_auto_opaque_decode_ref` exists for struct `RustOpaqueBase<RwLock<[u8]>, MoiArc<RwLock<[u8]>>>`, but its trait bounds were not satisfied
SEVERE:   --> src/frb_generated.rs:68:41
SEVERE:    |
SEVERE: 68 |                 let api_seed = api_seed.rust_auto_opaque_decode_ref();
SEVERE:    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `RustOpaqueBase<RwLock<[u8]>, MoiArc<RwLock<[u8]>>>` due to unsatisfied trait bounds


### Expected behavior

build success

### Generated binding code

```shell
// This file is automatically generated, so please do not edit it.
// Generated by `flutter_rust_bridge`@ 2.0.0-dev.29.

// 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';

String privateKeyNew({dynamic hint}) =>
    RustLib.instance.api.privateKeyNew(hint: hint);

String fromSeedUnchecked({required U8 seed, dynamic hint}) =>
    RustLib.instance.api.fromSeedUnchecked(seed: seed, hint: hint);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::rust_async::RwLock<[u8]>>
@sealed
class U8 extends RustOpaque {
  U8.dcoDecode(List<dynamic> wire) : super.dcoDecode(wire, _kStaticData);

  U8.sseDecode(int ptr, int externalSizeOnNative)
      : super.sseDecode(ptr, externalSizeOnNative, _kStaticData);

  static final _kStaticData = RustArcStaticData(
    rustArcIncrementStrongCount:
        RustLib.instance.api.rust_arc_increment_strong_count_U8,
    rustArcDecrementStrongCount:
        RustLib.instance.api.rust_arc_decrement_strong_count_U8,
    rustArcDecrementStrongCountPtr:
        RustLib.instance.api.rust_arc_decrement_strong_count_U8Ptr,
  );
}

OS

mac os

Version of flutter_rust_bridge_codegen

^2.0.0-dev.29

Flutter info

[✓] Flutter (Channel stable, 3.19.3, on macOS 14.3 23D56 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.19.3 on channel stable at /Users/gtmickey/flutter_3.19.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (4 周前), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/gtmickey/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/gtmickey/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

Version of clang++

No response

Additional context

No response

Hi! Thanks for opening your first issue here! 😄

Hi, does Vec<u8> work for you?

it works, thanks

You are welcome!

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.