fromWire static method
Decode an externally-tagged NodeState.
Implementation
static NodeState fromWire(Object? value) {
if (value is String) {
if (value == 'Opaque') return const NodeStateOpaque();
throw FormatException('unknown NodeState unit variant: $value');
}
final entry = _tagged(value, 'NodeState');
switch (entry.key) {
case 'Payload':
return NodeStatePayload(_bytesFromWire(entry.value));
case 'SharedBlob':
return NodeStateSharedBlob(ShmBlobRef.fromWire(entry.value));
case 'Opaque':
return const NodeStateOpaque();
default:
throw FormatException('unknown NodeState variant: ${entry.key}');
}
}