mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
veilidchat work
This commit is contained in:
parent
d48ce521b2
commit
4078c00098
@ -55,6 +55,8 @@ sealed class DHTSchema with _$DHTSchema {
|
|||||||
_$DHTSchemaFromJson(json);
|
_$DHTSchemaFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DHTSchema defaultDHTSchema = DHTSchema.dflt(oCnt: 1);
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class DHTSchemaMember with _$DHTSchemaMember {
|
class DHTSchemaMember with _$DHTSchemaMember {
|
||||||
@Assert('mCnt > 0 && mCnt <= 65535', 'value out of range')
|
@Assert('mCnt > 0 && mCnt <= 65535', 'value out of range')
|
||||||
|
@ -47,6 +47,19 @@ abstract class EncodedString extends Equatable {
|
|||||||
@override
|
@override
|
||||||
String toString() => contents;
|
String toString() => contents;
|
||||||
|
|
||||||
|
static T fromBytes<T extends EncodedString>(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<T extends EncodedString>(String s) {
|
static T fromString<T extends EncodedString>(String s) {
|
||||||
switch (T) {
|
switch (T) {
|
||||||
case FixedEncodedString32:
|
case FixedEncodedString32:
|
||||||
@ -72,6 +85,13 @@ class FixedEncodedString32 extends EncodedString {
|
|||||||
return 24;
|
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) {
|
factory FixedEncodedString32.fromString(String s) {
|
||||||
var d = base64UrlNoPadDecode(s);
|
var d = base64UrlNoPadDecode(s);
|
||||||
if (d.length != decodedLength()) {
|
if (d.length != decodedLength()) {
|
||||||
@ -96,6 +116,13 @@ class FixedEncodedString43 extends EncodedString {
|
|||||||
return 32;
|
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) {
|
factory FixedEncodedString43.fromString(String s) {
|
||||||
var d = base64UrlNoPadDecode(s);
|
var d = base64UrlNoPadDecode(s);
|
||||||
if (d.length != decodedLength()) {
|
if (d.length != decodedLength()) {
|
||||||
@ -124,6 +151,13 @@ class FixedEncodedString86 extends EncodedString {
|
|||||||
return toString();
|
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) {
|
factory FixedEncodedString86.fromString(String s) {
|
||||||
var d = base64UrlNoPadDecode(s);
|
var d = base64UrlNoPadDecode(s);
|
||||||
if (d.length != decodedLength()) {
|
if (d.length != decodedLength()) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "veilid-python"
|
name = "veilid"
|
||||||
version = "0.1.0"
|
version = "0.5.0"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Christien Rioux <chris@veilid.org>"]
|
authors = ["Veilid Team <contact@veilid.com>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
packages = [{include = "veilid"}]
|
packages = [{include = "veilid"}]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user