narupatools.core.protobuf¶
Protobuf utilities which support more options than the base Narupa converter.
Functions
Convert an arbitrary mapping to a protobuf Struct. |
|
Update a protobuf struct in place from a dictionary-like object. |
-
narupatools.core.protobuf.dictionary_to_protobuf(mapping: Mapping[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]]) → google.protobuf.struct_pb2.Struct¶ Convert an arbitrary mapping to a protobuf Struct.
Improved version of
dict_to_struct(), that can serialize more complex types such as iterables, mappings and NumPy arrays.- Parameters
mapping – Dictionary to convert.
- Returns
Structcontaining copies of all the items of the dictionary.
-
narupatools.core.protobuf.update_struct(struct: google.protobuf.struct_pb2.Struct, mapping: Mapping[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]]) → None¶ Update a protobuf struct in place from a dictionary-like object.
- Parameters
struct – Struct to update.
mapping – Mapping to provide values to insert into struct.
Exceptions
|
Error raised when something cannot be serialized to protobuf. |