| Flutter Linux Embedder |

Macros | Enumerations | Functions
fl_message_codec.h File Reference
`#include <glib-object.h>`
`#include <gmodule.h>`
`#include "fl_value.h"`

Go to the source code of this file.

## Macros
#define | FL_MESSAGE_CODEC_ERROR fl_message_codec_error_quark()

## Enumerations
enum | FlMessageCodecError { FL_MESSAGE_CODEC_ERROR_FAILED , FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA , FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA , FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE }

## Functions
G_MODULE_EXPORT GQuark | fl_message_codec_error_quark (void) G_GNUC_CONST
G_MODULE_EXPORT | G_DECLARE_DERIVABLE_TYPE (FlMessageCodec, fl_message_codec, FL, MESSAGE_CODEC, GObject) struct _FlMessageCodecClass
GBytes * | fl_message_codec_encode_message (FlMessageCodec *codec, FlValue *message, GError **error)
FlValue * | fl_message_codec_decode_message (FlMessageCodec *codec, GBytes *message, GError **error)

## Macro Definition Documentation

## ◆ FL_MESSAGE_CODEC_ERROR

#define FL_MESSAGE_CODEC_ERROR fl_message_codec_error_quark()

FlMessageCodecError: @FL_MESSAGE_CODEC_ERROR_FAILED: Codec failed due to an unspecified error. @FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA: Codec ran out of data reading a value. @FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA: Additional data encountered in message. @FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE: Codec encountered an unsupported FlValue.

Errors for #FlMessageCodec objects to set on failures.

Definition at line 30 of file fl_message_codec.h.

## Enumeration Type Documentation

## ◆ FlMessageCodecError

enum FlMessageCodecError

Enumerator
FL_MESSAGE_CODEC_ERROR_FAILED |
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA |
FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA |
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE |

Definition at line 32 of file fl_message_codec.h.

32 {
33 FL_MESSAGE_CODEC_ERROR_FAILED,
34 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA,
35 FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA,
36 FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE,
37 } FlMessageCodecError;
FlMessageCodecError
FlMessageCodecError
Definition: fl_message_codec.h:32
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
Definition: fl_message_codec.h:34
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
@ FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
Definition: fl_message_codec.h:36
FL_MESSAGE_CODEC_ERROR_FAILED
@ FL_MESSAGE_CODEC_ERROR_FAILED
Definition: fl_message_codec.h:33
FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
@ FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
Definition: fl_message_codec.h:35

## Function Documentation

## ◆ fl_message_codec_decode_message()

FlValue* fl_message_codec_decode_message | ( | FlMessageCodec * | codec,
|  | GBytes * | message,
|  | GError ** | error
| ) |  |

fl_message_codec_decode_message: @codec: an #FlMessageCodec. @message: binary message to decode. @error: (allow-none): #GError location to store the error occurring, or NULL. If `error` is not NULL, `*error` must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Decodes a message from a binary encoding.

Returns: an FlValue or NULL on error.

Definition at line 33 of file fl_message_codec.cc.

35 {
36 g_return_val_if_fail(FL_IS_MESSAGE_CODEC(self), nullptr);
37 g_return_val_if_fail(message != nullptr, nullptr);
38
39 return FL_MESSAGE_CODEC_GET_CLASS(self)->decode_message(self, message, error);
40 }
message
const char * message
Definition: fl_accessibility_handler.cc:21
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References error, and message.

Referenced by decode_error_value(), decode_message(), decode_message_with_codec(), decode_semantic_data(), fl_basic_message_channel_send_finish(), fl_json_method_codec_decode_method_call(), fl_json_method_codec_decode_response(), message_cb(), and TEST().

## ◆ fl_message_codec_encode_message()

GBytes* fl_message_codec_encode_message | ( | FlMessageCodec * | codec,
|  | FlValue * | message,
|  | GError ** | error
| ) |  |

fl_message_codec_encode_message: @codec: an #FlMessageCodec. @buffer: buffer to write to. @message: message to encode or NULL to encode the null value. @error: (allow-none): #GError location to store the error occurring, or NULL. If `error` is not NULL, `*error` must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Encodes a message into a binary representation.

Returns: a binary encoded message or NULL on error.

Definition at line 17 of file fl_message_codec.cc.

19 {
20 g_return_val_if_fail(FL_IS_MESSAGE_CODEC(self), nullptr);
21
22 // If the user provided NULL, then make a temporary FlValue object for this to
23 // make it simpler for the subclasses.
24 g_autoptr(FlValue) null_value = nullptr;
25 if (message == nullptr) {
26 null_value = fl_value_new_null();
27 message = null_value;
28 }
29
30 return FL_MESSAGE_CODEC_GET_CLASS(self)->encode_message(self, message, error);
31 }
g_autoptr
g_autoptr(FlEngine) engine
fl_value_new_null
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:251
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42

References error, fl_value_new_null(), g_autoptr(), and message.

Referenced by encode_message(), encode_message_error(), encode_message_with_codec(), fl_accessible_text_field_perform_action(), fl_basic_message_channel_respond(), fl_basic_message_channel_send(), fl_json_method_codec_encode_error_envelope(), fl_json_method_codec_encode_method_call(), fl_json_method_codec_encode_success_envelope(), perform_set_selection_action(), perform_set_text_action(), send_lifecycle_state(), and TEST().

## ◆ fl_message_codec_error_quark()

G_MODULE_EXPORT GQuark fl_message_codec_error_quark | ( | void |  | ) |

## ◆ G_DECLARE_DERIVABLE_TYPE()

G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE | ( | FlMessageCodec | ,
|  | fl_message_codec | ,
|  | FL | ,
|  | MESSAGE_CODEC | ,
|  | GObject |
| ) |  |

FlMessageCodec:

#FlMessageCodec is a message encoding/decoding mechanism that operates on FlValue objects. Both operations returns errors if the conversion fails. Such situations should be treated as programming errors.

#FlMessageCodec matches the MethodCodec class in the Flutter services library.

FlMessageCodec::encode_message: @codec: an #FlMessageCodec. @message: message to encode or NULL to encode the null value. @error: (allow-none): #GError location to store the error occurring, or NULL. If `error` is not NULL, `*error` must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Virtual method to encode a message. A subclass must implement this method. If the subclass cannot handle the type of @message then it must generate a FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE error.

Returns: a binary message or NULL on error.

FlMessageCodec::decode_message: @codec: an #FlMessageCodec. @message: binary message to decode. @error: (allow-none): #GError location to store the error occurring, or NULL. If `error` is not NULL, `*error` must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Virtual method to decode a message. A subclass must implement this method. If @message is too small then a FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA error must be generated. If @message is too large then a FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA error must be generated.

Returns: an FlValue or NULL on error.

Definition at line 43 of file fl_message_codec.h.

60 {
61 GObjectClass parent_class;
62
63 /**
64 * FlMessageCodec::encode_message:
65 * @codec: an #FlMessageCodec.
66 * @message: message to encode or %NULL to encode the null value.
67 * @error: (allow-none): #GError location to store the error occurring, or
68 * %NULL. If `error` is not %NULL, `*error` must be initialized (typically
69 * %NULL, but an error from a previous call using GLib error handling is
70 * explicitly valid).
71 *
72 * Virtual method to encode a message. A subclass must implement this method.
73 * If the subclass cannot handle the type of @message then it must generate a
74 * FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE error.
75 *
76 * Returns: a binary message or %NULL on error.
77 */
78 GBytes* (*encode_message)(FlMessageCodec* codec,
79 FlValue* message,
80 GError** error);
81
82 /**
83 * FlMessageCodec::decode_message:
84 * @codec: an #FlMessageCodec.
85 * @message: binary message to decode.
86 * @error: (allow-none): #GError location to store the error occurring, or
87 * %NULL. If `error` is not %NULL, `*error` must be initialized (typically
88 * %NULL, but an error from a previous call using GLib error handling is
89 * explicitly valid).
90 *
91 * Virtual method to decode a message. A subclass must implement this method.
92 * If @message is too small then a #FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA error
93 * must be generated. If @message is too large then a
94 * #FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA error must be generated.
95 *
96 * Returns: an #FlValue or %NULL on error.
97 */
98 FlValue* (*decode_message)(FlMessageCodec* codec,
99 GBytes* message,
100 GError** error);
101 };

References error, and message.