diff --git a/veilid-flutter/lib/routing_context.dart b/veilid-flutter/lib/routing_context.dart index fdd7fd1e..84dd7eaa 100644 --- a/veilid-flutter/lib/routing_context.dart +++ b/veilid-flutter/lib/routing_context.dart @@ -55,6 +55,8 @@ sealed class DHTSchema with _$DHTSchema { _$DHTSchemaFromJson(json); } +const DHTSchema defaultDHTSchema = DHTSchema.dflt(oCnt: 1); + @freezed class DHTSchemaMember with _$DHTSchemaMember { @Assert('mCnt > 0 && mCnt <= 65535', 'value out of range') diff --git a/veilid-flutter/lib/veilid_encoding.dart b/veilid-flutter/lib/veilid_encoding.dart index 23fa8362..d6334139 100644 --- a/veilid-flutter/lib/veilid_encoding.dart +++ b/veilid-flutter/lib/veilid_encoding.dart @@ -47,6 +47,19 @@ abstract class EncodedString extends Equatable { @override String toString() => contents; + static T fromBytes(Uint8List bytes) { + switch (T) { + case FixedEncodedString32: + return FixedEncodedString32.fromBytes(bytes) as T; + case FixedEncodedString43: + return FixedEncodedString43.fromBytes(bytes) as T; + case FixedEncodedString86: + return FixedEncodedString86.fromBytes(bytes) as T; + default: + throw UnimplementedError(); + } + } + static T fromString(String s) { switch (T) { case FixedEncodedString32: @@ -72,6 +85,13 @@ class FixedEncodedString32 extends EncodedString { return 24; } + factory FixedEncodedString32.fromBytes(Uint8List bytes) { + if (bytes.length != decodedLength()) { + throw Exception("length ${bytes.length} should be ${decodedLength()}"); + } + return FixedEncodedString32._(base64UrlNoPadEncode(bytes)); + } + factory FixedEncodedString32.fromString(String s) { var d = base64UrlNoPadDecode(s); if (d.length != decodedLength()) { @@ -96,6 +116,13 @@ class FixedEncodedString43 extends EncodedString { return 32; } + factory FixedEncodedString43.fromBytes(Uint8List bytes) { + if (bytes.length != decodedLength()) { + throw Exception("length ${bytes.length} should be ${decodedLength()}"); + } + return FixedEncodedString43._(base64UrlNoPadEncode(bytes)); + } + factory FixedEncodedString43.fromString(String s) { var d = base64UrlNoPadDecode(s); if (d.length != decodedLength()) { @@ -124,6 +151,13 @@ class FixedEncodedString86 extends EncodedString { return toString(); } + factory FixedEncodedString86.fromBytes(Uint8List bytes) { + if (bytes.length != decodedLength()) { + throw Exception("length ${bytes.length} should be ${decodedLength()}"); + } + return FixedEncodedString86._(base64UrlNoPadEncode(bytes)); + } + factory FixedEncodedString86.fromString(String s) { var d = base64UrlNoPadDecode(s); if (d.length != decodedLength()) { diff --git a/veilid-python/pyproject.toml b/veilid-python/pyproject.toml index 7b59ddd4..93eae34f 100644 --- a/veilid-python/pyproject.toml +++ b/veilid-python/pyproject.toml @@ -1,8 +1,8 @@ [tool.poetry] -name = "veilid-python" -version = "0.1.0" +name = "veilid" +version = "0.5.0" description = "" -authors = ["Christien Rioux "] +authors = ["Veilid Team "] readme = "README.md" packages = [{include = "veilid"}]