Flutter Linux Embedder
fl_message_codec.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_MESSAGE_CODEC_H_
6
#define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_MESSAGE_CODEC_H_
7
8
#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9
#error "Only <flutter_linux/flutter_linux.h> can be included directly."
10
#endif
11
12
#include <glib-object.h>
13
#include <gmodule.h>
14
15
#include "
fl_value.h
"
16
17
G_BEGIN_DECLS
18
19
/**
20
* FlMessageCodecError:
21
* @FL_MESSAGE_CODEC_ERROR_FAILED: Codec failed due to an unspecified error.
22
* @FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA: Codec ran out of data reading a value.
23
* @FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA: Additional data encountered in
24
* message.
25
* @FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE: Codec encountered an unsupported
26
* #FlValue.
27
*
28
* Errors for #FlMessageCodec objects to set on failures.
29
*/
30
#define FL_MESSAGE_CODEC_ERROR fl_message_codec_error_quark()
31
32
typedef
enum
{
33
// NOLINTBEGIN(readability-identifier-naming)
34
FL_MESSAGE_CODEC_ERROR_FAILED
,
35
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
,
36
FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
,
37
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
,
38
// NOLINTEND(readability-identifier-naming)
39
}
FlMessageCodecError
;
40
41
GQuark
fl_message_codec_error_quark
(
void
) G_GNUC_CONST;
42
43
G_MODULE_EXPORT
44
G_DECLARE_DERIVABLE_TYPE
(FlMessageCodec,
45
fl_message_codec,
46
FL
,
47
MESSAGE_CODEC,
48
GObject)
49
50
/**
51
* FlMessageCodec:
52
*
53
* #FlMessageCodec is a message encoding/decoding mechanism that operates on
54
* #FlValue objects. Both operations returns errors if the conversion fails.
55
* Such situations should be treated as programming errors.
56
*
57
* #FlMessageCodec matches the MethodCodec class in the Flutter services
58
* library.
59
*/
60
61
struct
_FlMessageCodecClass {
62
GObjectClass parent_class;
63
64
/**
65
* FlMessageCodec::encode_message:
66
* @codec: A #FlMessageCodec.
67
* @message: message to encode or %NULL to encode the null value.
68
* @error: (allow-none): #GError location to store the error occurring, or
69
* %NULL.
70
*
71
* Virtual method to encode a message. A subclass must implement this method.
72
* If the subclass cannot handle the type of @message then it must generate a
73
* FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE error.
74
*
75
* Returns: a binary message or %NULL on error.
76
*/
77
GBytes* (*encode_message)(FlMessageCodec* codec,
78
FlValue
* message,
79
GError**
error
);
80
81
/**
82
* FlMessageCodec::decode_message:
83
* @codec: an #FlMessageCodec.
84
* @message: binary message to decode.
85
* @error: (allow-none): #GError location to store the error occurring, or
86
* %NULL.
87
*
88
* Virtual method to decode a message. A subclass must implement this method.
89
* If @message is too small then a #FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA error
90
* must be generated. If @message is too large then a
91
* #FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA error must be generated.
92
*
93
* Returns: an #FlValue or %NULL on error.
94
*/
95
FlValue
* (*decode_message)(FlMessageCodec* codec,
96
GBytes* message,
97
GError**
error
);
98
};
99
100
/**
101
* fl_message_codec_encode_message:
102
* @codec: an #FlMessageCodec.
103
* @buffer: buffer to write to.
104
* @message: message to encode or %NULL to encode the null value.
105
* @error: (allow-none): #GError location to store the error occurring, or
106
* %NULL.
107
*
108
* Encodes a message into a binary representation.
109
*
110
* Returns: a binary encoded message or %NULL on error.
111
*/
112
GBytes*
fl_message_codec_encode_message
(FlMessageCodec* codec,
113
FlValue
* message,
114
GError**
error
);
115
116
/**
117
* fl_message_codec_decode_message:
118
* @codec: an #FlMessageCodec.
119
* @message: binary message to decode.
120
* @error: (allow-none): #GError location to store the error occurring, or
121
* %NULL.
122
*
123
* Decodes a message from a binary encoding.
124
*
125
* Returns: an #FlValue or %NULL on error.
126
*/
127
FlValue
*
fl_message_codec_decode_message
(FlMessageCodec* codec,
128
GBytes* message,
129
GError**
error
);
130
131
G_END_DECLS
132
133
#endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_MESSAGE_CODEC_H_
FlMessageCodecError
FlMessageCodecError
Definition:
fl_message_codec.h:32
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition:
fl_value.h:40
FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
@ FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA
Definition:
fl_message_codec.h:36
G_DECLARE_DERIVABLE_TYPE
G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE(FlMessageCodec, fl_message_codec, FL, MESSAGE_CODEC, GObject) struct _FlMessageCodecClass
Definition:
fl_message_codec.h:44
FL_MESSAGE_CODEC_ERROR_FAILED
@ FL_MESSAGE_CODEC_ERROR_FAILED
Definition:
fl_message_codec.h:34
FL
FL
Definition:
fl_binary_messenger.cc:27
fl_message_codec_encode_message
GBytes * fl_message_codec_encode_message(FlMessageCodec *codec, FlValue *message, GError **error)
Definition:
fl_message_codec.cc:17
FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
Definition:
fl_message_codec.h:35
fl_value.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition:
fl_pixel_buffer_texture_test.cc:40
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
@ FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
Definition:
fl_message_codec.h:37
fl_message_codec_error_quark
GQuark fl_message_codec_error_quark(void) G_GNUC_CONST
fl_message_codec_decode_message
FlValue * fl_message_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)
Definition:
fl_message_codec.cc:33
shell
platform
linux
public
flutter_linux
fl_message_codec.h
Generated by
1.8.17