Skip to content

Commit

Permalink
fix(gebura): wrap TraceMode
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Dec 29, 2023
1 parent 1570485 commit 8f8fa03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/bloc/gebura/gebura_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:tuihub_protos/librarian/v1/common.pb.dart';

import '../../common/bloc_event_status_mixin.dart';
import '../../ffi/ffi.dart';
import '../../ffi/rust_ffi/rust_ffi.dart';
import '../../ffi/ffi_model.dart';
import '../../model/gebura_model.dart';
import '../../repo/grpc/api_helper.dart';
import '../../repo/local/gebura.dart';
Expand Down
7 changes: 5 additions & 2 deletions lib/ffi/ffi_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'rust_ffi/rust_ffi.dart';

abstract class FFIBase {
Future<(int, int, bool)> processRunner(
TraceMode mode,
Expand All @@ -13,3 +11,8 @@ abstract class FFIBase {
throw UnimplementedError();
}
}

enum TraceMode {
Simple,
ByName,
}
8 changes: 5 additions & 3 deletions lib/ffi/native_ffi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:ffi';
import 'dart:io';

import 'ffi_model.dart';
import 'rust_ffi/rust_ffi.dart';
import 'rust_ffi/rust_ffi.dart' as rust_ffi;

class NativeFFI {
NativeFFI._();
Expand Down Expand Up @@ -30,7 +30,7 @@ class NativeFFI {
}

class FFI extends FFIBase {
static final _ffi = RustFfiImpl(NativeFFI.dyLib);
static final _ffi = rust_ffi.RustFfiImpl(NativeFFI.dyLib);

@override
Future<(int, int, bool)> processRunner(
Expand All @@ -49,7 +49,9 @@ class FFI extends FFIBase {
workingDir: workingDir,
sleepCount: sleepCount,
sleepMillis: sleepMillis,
mode: mode,
mode: mode == TraceMode.Simple
? rust_ffi.TraceMode.Simple
: rust_ffi.TraceMode.ByName,
);
}
}

0 comments on commit 8f8fa03

Please sign in to comment.