diff --git a/packages/moxxmpp/lib/moxxmpp.dart b/packages/moxxmpp/lib/moxxmpp.dart index cd47ded..9d74481 100644 --- a/packages/moxxmpp/lib/moxxmpp.dart +++ b/packages/moxxmpp/lib/moxxmpp.dart @@ -31,7 +31,7 @@ export 'package:moxxmpp/src/socket.dart'; export 'package:moxxmpp/src/stanza.dart'; export 'package:moxxmpp/src/stringxml.dart'; export 'package:moxxmpp/src/types/error.dart'; -export 'package:moxxmpp/src/types/resultv2.dart'; +export 'package:moxxmpp/src/types/result.dart'; export 'package:moxxmpp/src/xeps/staging/extensible_file_thumbnails.dart'; export 'package:moxxmpp/src/xeps/staging/file_upload_notification.dart'; export 'package:moxxmpp/src/xeps/xep_0004.dart'; diff --git a/packages/moxxmpp/lib/src/types/result.dart b/packages/moxxmpp/lib/src/types/result.dart index 4a0984a..06cabb9 100644 --- a/packages/moxxmpp/lib/src/types/result.dart +++ b/packages/moxxmpp/lib/src/types/result.dart @@ -1,13 +1,13 @@ -/// Class that is supposed to by used with a state type S and a value type V. -/// The state indicates if an action was successful or not, while the value -/// type indicates the return value, i.e. a result in a computation or the -/// actual error description. -class Result { +class Result { - Result(S state, V value) : _state = state, _value = value; - final S _state; - final V _value; + const Result(this._data) : assert(_data is T || _data is V, 'Invalid data type: Must be either $T or $V'); + final dynamic _data; - S getState() => _state; - V getValue() => _value; + bool isType() => _data is S; + + S get() { + assert(_data is S, 'Data is not $S'); + + return _data as S; + } } diff --git a/packages/moxxmpp/lib/src/types/resultv2.dart b/packages/moxxmpp/lib/src/types/resultv2.dart deleted file mode 100644 index 06cabb9..0000000 --- a/packages/moxxmpp/lib/src/types/resultv2.dart +++ /dev/null @@ -1,13 +0,0 @@ -class Result { - - const Result(this._data) : assert(_data is T || _data is V, 'Invalid data type: Must be either $T or $V'); - final dynamic _data; - - bool isType() => _data is S; - - S get() { - assert(_data is S, 'Data is not $S'); - - return _data as S; - } -} diff --git a/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart b/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart index 4e31763..ed594e1 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart @@ -10,7 +10,7 @@ import 'package:moxxmpp/src/namespaces.dart'; import 'package:moxxmpp/src/presence.dart'; import 'package:moxxmpp/src/stanza.dart'; import 'package:moxxmpp/src/stringxml.dart'; -import 'package:moxxmpp/src/types/resultv2.dart'; +import 'package:moxxmpp/src/types/result.dart'; import 'package:moxxmpp/src/xeps/xep_0004.dart'; import 'package:moxxmpp/src/xeps/xep_0030/errors.dart'; import 'package:moxxmpp/src/xeps/xep_0030/helpers.dart'; diff --git a/packages/moxxmpp/lib/src/xeps/xep_0060/xep_0060.dart b/packages/moxxmpp/lib/src/xeps/xep_0060/xep_0060.dart index e492b45..2cbf409 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0060/xep_0060.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0060/xep_0060.dart @@ -7,7 +7,7 @@ import 'package:moxxmpp/src/managers/namespaces.dart'; import 'package:moxxmpp/src/namespaces.dart'; import 'package:moxxmpp/src/stanza.dart'; import 'package:moxxmpp/src/stringxml.dart'; -import 'package:moxxmpp/src/types/resultv2.dart'; +import 'package:moxxmpp/src/types/result.dart'; import 'package:moxxmpp/src/xeps/xep_0004.dart'; import 'package:moxxmpp/src/xeps/xep_0030/errors.dart'; import 'package:moxxmpp/src/xeps/xep_0030/types.dart'; diff --git a/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart b/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart index e88db31..8cdb255 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart @@ -12,7 +12,7 @@ import 'package:moxxmpp/src/managers/namespaces.dart'; import 'package:moxxmpp/src/namespaces.dart'; import 'package:moxxmpp/src/stanza.dart'; import 'package:moxxmpp/src/stringxml.dart'; -import 'package:moxxmpp/src/types/resultv2.dart'; +import 'package:moxxmpp/src/types/result.dart'; import 'package:moxxmpp/src/xeps/xep_0030/errors.dart'; import 'package:moxxmpp/src/xeps/xep_0030/types.dart'; import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';