feat: Move the result type into moxlib
This commit is contained in:
parent
3829c6c11b
commit
207215cc5f
@ -11,4 +11,3 @@ analyzer:
|
|||||||
exclude:
|
exclude:
|
||||||
- "lib/src/protobuf/*.dart"
|
- "lib/src/protobuf/*.dart"
|
||||||
- "example/omemo_dart_example.dart"
|
- "example/omemo_dart_example.dart"
|
||||||
- "test/serialisation_test.dart"
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
// TODO: Pull into moxlib
|
|
||||||
class Result<T, V> {
|
|
||||||
const Result(this._data)
|
|
||||||
: assert(
|
|
||||||
_data is T || _data is V,
|
|
||||||
'Invalid data type $_data: Must be either $T or $V',
|
|
||||||
);
|
|
||||||
final dynamic _data;
|
|
||||||
|
|
||||||
bool isType<S>() => _data is S;
|
|
||||||
|
|
||||||
S get<S>() {
|
|
||||||
assert(_data is S, 'Data is not $S');
|
|
||||||
|
|
||||||
return _data as S;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object get dataRuntimeType => _data.runtimeType;
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:cryptography/cryptography.dart';
|
import 'package:cryptography/cryptography.dart';
|
||||||
import 'package:omemo_dart/src/common/result.dart';
|
import 'package:moxlib/moxlib.dart';
|
||||||
import 'package:omemo_dart/src/errors.dart';
|
import 'package:omemo_dart/src/errors.dart';
|
||||||
import 'package:omemo_dart/src/keys.dart';
|
import 'package:omemo_dart/src/keys.dart';
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:cryptography/cryptography.dart';
|
import 'package:cryptography/cryptography.dart';
|
||||||
import 'package:hex/hex.dart';
|
import 'package:hex/hex.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:moxlib/moxlib.dart';
|
||||||
import 'package:omemo_dart/src/common/constants.dart';
|
import 'package:omemo_dart/src/common/constants.dart';
|
||||||
import 'package:omemo_dart/src/common/result.dart';
|
|
||||||
import 'package:omemo_dart/src/crypto.dart';
|
import 'package:omemo_dart/src/crypto.dart';
|
||||||
import 'package:omemo_dart/src/double_ratchet/kdf.dart';
|
import 'package:omemo_dart/src/double_ratchet/kdf.dart';
|
||||||
import 'package:omemo_dart/src/errors.dart';
|
import 'package:omemo_dart/src/errors.dart';
|
||||||
|
@ -4,8 +4,8 @@ import 'package:collection/collection.dart';
|
|||||||
import 'package:cryptography/cryptography.dart';
|
import 'package:cryptography/cryptography.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:moxlib/moxlib.dart';
|
||||||
import 'package:omemo_dart/src/common/constants.dart';
|
import 'package:omemo_dart/src/common/constants.dart';
|
||||||
import 'package:omemo_dart/src/common/result.dart';
|
|
||||||
import 'package:omemo_dart/src/crypto.dart';
|
import 'package:omemo_dart/src/crypto.dart';
|
||||||
import 'package:omemo_dart/src/double_ratchet/double_ratchet.dart';
|
import 'package:omemo_dart/src/double_ratchet/double_ratchet.dart';
|
||||||
import 'package:omemo_dart/src/errors.dart';
|
import 'package:omemo_dart/src/errors.dart';
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:cryptography/cryptography.dart';
|
import 'package:cryptography/cryptography.dart';
|
||||||
|
import 'package:moxlib/moxlib.dart';
|
||||||
import 'package:omemo_dart/src/common/constants.dart';
|
import 'package:omemo_dart/src/common/constants.dart';
|
||||||
import 'package:omemo_dart/src/common/result.dart';
|
|
||||||
import 'package:omemo_dart/src/crypto.dart';
|
import 'package:omemo_dart/src/crypto.dart';
|
||||||
import 'package:omemo_dart/src/errors.dart';
|
import 'package:omemo_dart/src/errors.dart';
|
||||||
import 'package:omemo_dart/src/helpers.dart';
|
import 'package:omemo_dart/src/helpers.dart';
|
||||||
|
@ -13,6 +13,9 @@ dependencies:
|
|||||||
hex: ^0.2.0
|
hex: ^0.2.0
|
||||||
logging: ^1.0.2
|
logging: ^1.0.2
|
||||||
meta: ^1.7.0
|
meta: ^1.7.0
|
||||||
|
moxlib:
|
||||||
|
version: ^0.2.0
|
||||||
|
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||||
pinenacl: ^0.5.1
|
pinenacl: ^0.5.1
|
||||||
protobuf: ^2.1.0
|
protobuf: ^2.1.0
|
||||||
protoc_plugin: ^20.0.1
|
protoc_plugin: ^20.0.1
|
||||||
|
Loading…
Reference in New Issue
Block a user