ProtobufEncodingContext class
Context for encoding Protocol Buffers messages.
GRPC uses Protocol Buffers messages, so you can this with GRPC too.
Example
import 'package:kind/kind.dart';
void main() {
final context = ProtobufEncodingContext();
final greeting = Greeting();
final bytes = context.encodeBytes(greeting, kind: Greeting.kind);
}
class Greeting {
static final EntityKind<Greeting> kind = EntityKind<Greeting>(
name: 'Example',
define: (c) {
c.requiredString(
id: 1, // <-- Protocol Buffers field ID
name: 'message', // <-- Protocol Buffers field name
getter: (t) => t.message,
setter: (t,v) => t.message = v;
);
c.constructor = () => Greeting();
},
);
String message = 'Hello world!';
}
- Inheritance
-
- Object
- EncodingContext
- ProtobufEncodingContext
Constructors
- ProtobufEncodingContext({KindLibrary? kindLibrary, Namer? namer})
Properties
- errorPrimaryLabel → String
-
Primary label for errors constructed by newGraphNodeError.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- kindLibrary → KindLibrary?
-
Optional library of available kinds.
finalinherited
- namer → Namer?
-
Translates names of kinds and properties. Default is null.
finalinherited
-
pathEdges
→ List<
Object?> -
Path from root node to the current node.
finalinherited
-
pathNodes
→ List<
Object?> -
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
encode<
T> (T object, {required Kind< T> kind, int? pbType}) → Object -
Serializes the object using the given Kind.
override
-
encodeBytes<
T extends Object> (T object, {required EntityKind< T> kind}) → List<int> - Encodes an object as bytes.
-
enter(
Object? value) → void -
inherited
-
enterField(
String name, Object? value) → void -
Enters a field.
inherited
-
enterIndex(
int index, Object? value) → void -
Enters an index.
inherited
-
enterMapEntry(
String key, Object? value) → void -
Enters a map entry.
inherited
-
leave(
) → void -
Leaves the the top node.
inherited
-
newGraphNodeError(
{required Object? value, required String reason}) → GraphNodeError -
Constructs a new instance of GraphNodeError that describes the
location in the graph.
inherited
-
newUnsupportedTypeError(
Object? value) → GraphNodeError -
Returns a new error.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pathContainsValue(
Object? value) → bool -
Returns true if pathNodes has an identical value.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited