mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-07-27 17:05:27 -04:00
add lengths to typedkey
This commit is contained in:
parent
81134bad67
commit
6282bfd1c5
2 changed files with 60 additions and 0 deletions
|
@ -52,6 +52,32 @@ abstract class EncodedString extends Equatable {
|
|||
@override
|
||||
String toString() => contents;
|
||||
|
||||
static int encodedLength<T extends EncodedString>() {
|
||||
switch (T) {
|
||||
case FixedEncodedString32:
|
||||
return FixedEncodedString32.encodedLength();
|
||||
case FixedEncodedString43:
|
||||
return FixedEncodedString43.encodedLength();
|
||||
case FixedEncodedString86:
|
||||
return FixedEncodedString86.encodedLength();
|
||||
default:
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
static int decodedLength<T extends EncodedString>() {
|
||||
switch (T) {
|
||||
case FixedEncodedString32:
|
||||
return FixedEncodedString32.decodedLength();
|
||||
case FixedEncodedString43:
|
||||
return FixedEncodedString43.decodedLength();
|
||||
case FixedEncodedString86:
|
||||
return FixedEncodedString86.decodedLength();
|
||||
default:
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
static T fromBytes<T extends EncodedString>(Uint8List bytes) {
|
||||
switch (T) {
|
||||
case FixedEncodedString32:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue