Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc comments for DartSignal and RustSignal fields #362

Merged
merged 9 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/quality_control.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
code:
name: dart-and-rust-code
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings

steps:
- name: Checkout repository
Expand Down Expand Up @@ -55,11 +57,10 @@ jobs:
- name: Check for any errors
run: |
rustup target add wasm32-unknown-unknown
RUSTFLAGS="-D warnings"
cargo check
cargo check --release
cargo check --target wasm32-unknown-unknown
cargo check --target wasm32-unknown-unknown --release
cargo clippy
cargo clippy --release
cargo clippy --target wasm32-unknown-unknown
cargo clippy --target wasm32-unknown-unknown --release

- name: Analyze code
run: |
Expand Down
10 changes: 8 additions & 2 deletions flutter_ffi_plugin/lib/src/interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ typedef HandleRustSignal = void Function(int, Uint8List, Uint8List);
/// This type is generic, and the message
/// can be of any type declared in Protobuf.
class RustSignal<T> {
T message;
Uint8List binary;
/// The message instance of a class generated by Protobuf.
final T message;

/// Binary data included in the signal.
/// This field is useful for sending custom bytes
/// without the overhead of serialization/deserialization.
final Uint8List binary;

RustSignal(this.message, this.binary);
}
4 changes: 4 additions & 0 deletions rust_crate/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ use super::interface_web::*;
/// This type is generic, and the message
/// can be of any type declared in Protobuf.
pub struct DartSignal<T> {
/// The message instance of a struct generated by Protobuf.
pub message: T,
/// Binary data included in the signal.
/// This field is useful for sending custom bytes
/// without the overhead of serialization/deserialization.
pub binary: Vec<u8>,
}

Expand Down
3 changes: 1 addition & 2 deletions rust_crate/src/interface_os.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::debug_print;
use allo_isolate::{IntoDart, Isolate, ZeroCopyBuffer};
use backtrace::Backtrace;
use os_thread_local::ThreadLocal;
use std::cell::RefCell;
use std::future::Future;
Expand Down Expand Up @@ -35,7 +34,7 @@ where
#[cfg(debug_assertions)]
{
std::panic::set_hook(Box::new(|panic_info| {
let backtrace = Backtrace::new();
let backtrace = backtrace::Backtrace::new();
debug_print!("A panic occurred in Rust.\n{panic_info}\n{backtrace:?}");
}));
}
Expand Down
3 changes: 1 addition & 2 deletions rust_crate/src/interface_web.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::debug_print;
use js_sys::Uint8Array;
use std::future::Future;
use wasm_bindgen::prelude::*;
Expand All @@ -12,7 +11,7 @@ where
#[cfg(debug_assertions)]
{
std::panic::set_hook(Box::new(|panic_info| {
debug_print!("A panic occurred in Rust.\n{panic_info}");
crate::debug_print!("A panic occurred in Rust.\n{panic_info}");
}));
}

Expand Down
4 changes: 1 addition & 3 deletions rust_crate/src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::crate_in_macro_def)]

#[macro_export]
/// Writes the interface code
/// needed to communicate with Dart.
Expand All @@ -21,7 +19,7 @@ macro_rules! write_interface {

#[cfg(not(target_family = "wasm"))]
#[no_mangle]
pub extern "C" fn send_dart_signal_extern(
pub unsafe extern "C" fn send_dart_signal_extern(
message_id: i64,
message_pointer: *const u8,
message_size: usize,
Expand Down