ffi-bindings 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,205 @@
1
+ var _process;
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
9
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
13
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
16
+ // Trust me, you don't want to mess with it!
17
+ /* tslint:disable */
18
+ /* eslint-disable */
19
+ // @ts-nocheck
20
+ import * as wasmBundle from "./wasm-bindgen/index.js";
21
+ import { AbstractFfiConverterByteArray, FfiConverterDuration, FfiConverterInt32, FfiConverterOptional, FfiConverterUInt64, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString, uniffiCreateRecord } from "uniffi-bindgen-react-native";
22
+ // Get converters from the other files, if any.
23
+ var nativeModule = function nativeModule() {
24
+ return wasmBundle;
25
+ };
26
+ var uniffiCaller = new UniffiRustCaller(function () {
27
+ return new wasmBundle.RustCallStatus();
28
+ });
29
+ var uniffiIsDebug =
30
+ // @ts-ignore -- The process global might not be defined
31
+ (typeof process === "undefined" ? "undefined" : _typeof(process)) !== "object" ||
32
+ // @ts-ignore -- The process global might not be defined
33
+ ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) !== "production" || false;
34
+ /**
35
+ * Generated factory for {@link MediaRetentionPolicy} record objects.
36
+ */
37
+ export var MediaRetentionPolicy = function () {
38
+ var _defaults = function defaults() {
39
+ return {};
40
+ };
41
+ var create = function () {
42
+ return uniffiCreateRecord(_defaults);
43
+ }();
44
+ return Object.freeze({
45
+ /**
46
+ * Create a frozen instance of {@link MediaRetentionPolicy}, with defaults specified
47
+ * in Rust, in the {@link matrix_sdk_base} crate.
48
+ */
49
+ create: create,
50
+ /**
51
+ * Create a frozen instance of {@link MediaRetentionPolicy}, with defaults specified
52
+ * in Rust, in the {@link matrix_sdk_base} crate.
53
+ */
54
+ "new": create,
55
+ /**
56
+ * Defaults specified in the {@link matrix_sdk_base} crate.
57
+ */
58
+ defaults: function defaults() {
59
+ return Object.freeze(_defaults());
60
+ }
61
+ });
62
+ }();
63
+ var FfiConverterTypeMediaRetentionPolicy = function () {
64
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter) {
65
+ function FFIConverter() {
66
+ _classCallCheck(this, FFIConverter);
67
+ return _callSuper(this, FFIConverter, arguments);
68
+ }
69
+ _inherits(FFIConverter, _AbstractFfiConverter);
70
+ return _createClass(FFIConverter, [{
71
+ key: "read",
72
+ value: function read(from) {
73
+ return {
74
+ maxCacheSize: FfiConverterOptionalUInt64.read(from),
75
+ maxFileSize: FfiConverterOptionalUInt64.read(from),
76
+ lastAccessExpiry: FfiConverterOptionalDuration.read(from),
77
+ cleanupFrequency: FfiConverterOptionalDuration.read(from)
78
+ };
79
+ }
80
+ }, {
81
+ key: "write",
82
+ value: function write(value, into) {
83
+ FfiConverterOptionalUInt64.write(value.maxCacheSize, into);
84
+ FfiConverterOptionalUInt64.write(value.maxFileSize, into);
85
+ FfiConverterOptionalDuration.write(value.lastAccessExpiry, into);
86
+ FfiConverterOptionalDuration.write(value.cleanupFrequency, into);
87
+ }
88
+ }, {
89
+ key: "allocationSize",
90
+ value: function allocationSize(value) {
91
+ return FfiConverterOptionalUInt64.allocationSize(value.maxCacheSize) + FfiConverterOptionalUInt64.allocationSize(value.maxFileSize) + FfiConverterOptionalDuration.allocationSize(value.lastAccessExpiry) + FfiConverterOptionalDuration.allocationSize(value.cleanupFrequency);
92
+ }
93
+ }]);
94
+ }(AbstractFfiConverterByteArray);
95
+ ;
96
+ return new FFIConverter();
97
+ }();
98
+ var stringConverter = function () {
99
+ var encoder = new TextEncoder();
100
+ var decoder = new TextDecoder();
101
+ return {
102
+ stringToBytes: function stringToBytes(s) {
103
+ return encoder.encode(s);
104
+ },
105
+ bytesToString: function bytesToString(ab) {
106
+ return decoder.decode(ab);
107
+ },
108
+ stringByteLength: function stringByteLength(s) {
109
+ return encoder.encode(s).byteLength;
110
+ }
111
+ };
112
+ }();
113
+ var FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
114
+ /**
115
+ * Represents the state of a room encryption.
116
+ */
117
+ export var EncryptionState;
118
+ (function (EncryptionState) {
119
+ /**
120
+ * The room is encrypted.
121
+ */
122
+ EncryptionState[EncryptionState["Encrypted"] = 0] = "Encrypted";
123
+ /**
124
+ * The room is not encrypted.
125
+ */
126
+ EncryptionState[EncryptionState["NotEncrypted"] = 1] = "NotEncrypted";
127
+ /**
128
+ * The state of the room encryption is unknown, probably because the
129
+ * `/sync` did not provide all data needed to decide.
130
+ */
131
+ EncryptionState[EncryptionState["Unknown"] = 2] = "Unknown";
132
+ })(EncryptionState || (EncryptionState = {}));
133
+ var FfiConverterTypeEncryptionState = function () {
134
+ var ordinalConverter = FfiConverterInt32;
135
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter2) {
136
+ function FFIConverter() {
137
+ _classCallCheck(this, FFIConverter);
138
+ return _callSuper(this, FFIConverter, arguments);
139
+ }
140
+ _inherits(FFIConverter, _AbstractFfiConverter2);
141
+ return _createClass(FFIConverter, [{
142
+ key: "read",
143
+ value: function read(from) {
144
+ switch (ordinalConverter.read(from)) {
145
+ case 1:
146
+ return EncryptionState.Encrypted;
147
+ case 2:
148
+ return EncryptionState.NotEncrypted;
149
+ case 3:
150
+ return EncryptionState.Unknown;
151
+ default:
152
+ throw new UniffiInternalError.UnexpectedEnumCase();
153
+ }
154
+ }
155
+ }, {
156
+ key: "write",
157
+ value: function write(value, into) {
158
+ switch (value) {
159
+ case EncryptionState.Encrypted:
160
+ return ordinalConverter.write(1, into);
161
+ case EncryptionState.NotEncrypted:
162
+ return ordinalConverter.write(2, into);
163
+ case EncryptionState.Unknown:
164
+ return ordinalConverter.write(3, into);
165
+ }
166
+ }
167
+ }, {
168
+ key: "allocationSize",
169
+ value: function allocationSize(value) {
170
+ return ordinalConverter.allocationSize(0);
171
+ }
172
+ }]);
173
+ }(AbstractFfiConverterByteArray);
174
+ return new FFIConverter();
175
+ }();
176
+ // FfiConverter for UniffiDuration | undefined
177
+ var FfiConverterOptionalDuration = new FfiConverterOptional(FfiConverterDuration);
178
+ // FfiConverter for /*u64*/bigint | undefined
179
+ var FfiConverterOptionalUInt64 = new FfiConverterOptional(FfiConverterUInt64);
180
+ /**
181
+ * This should be called before anything else.
182
+ *
183
+ * It is likely that this is being done for you by the library's `index.ts`.
184
+ *
185
+ * It checks versions of uniffi between when the Rust scaffolding was generated
186
+ * and when the bindings were generated.
187
+ *
188
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
189
+ */
190
+ function uniffiEnsureInitialized() {
191
+ // Get the bindings contract version from our ComponentInterface
192
+ var bindingsContractVersion = 29;
193
+ // Get the scaffolding contract version by calling the into the dylib
194
+ var scaffoldingContractVersion = nativeModule().ubrn_ffi_matrix_sdk_base_uniffi_contract_version();
195
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
196
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
197
+ }
198
+ }
199
+ export default Object.freeze({
200
+ initialize: uniffiEnsureInitialized,
201
+ converters: {
202
+ FfiConverterTypeEncryptionState: FfiConverterTypeEncryptionState,
203
+ FfiConverterTypeMediaRetentionPolicy: FfiConverterTypeMediaRetentionPolicy
204
+ }
205
+ });
@@ -0,0 +1,169 @@
1
+ var _process;
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
9
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
13
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
16
+ // Trust me, you don't want to mess with it!
17
+ /* tslint:disable */
18
+ /* eslint-disable */
19
+ // @ts-nocheck
20
+ import * as wasmBundle from "./wasm-bindgen/index.js";
21
+ import { AbstractFfiConverterByteArray, FfiConverterInt32, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString } from "uniffi-bindgen-react-native";
22
+ // Get converters from the other files, if any.
23
+ var nativeModule = function nativeModule() {
24
+ return wasmBundle;
25
+ };
26
+ var uniffiCaller = new UniffiRustCaller(function () {
27
+ return new wasmBundle.RustCallStatus();
28
+ });
29
+ var uniffiIsDebug =
30
+ // @ts-ignore -- The process global might not be defined
31
+ (typeof process === "undefined" ? "undefined" : _typeof(process)) !== "object" ||
32
+ // @ts-ignore -- The process global might not be defined
33
+ ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) !== "production" || false;
34
+ // Public interface members begin here.
35
+ var stringConverter = function () {
36
+ var encoder = new TextEncoder();
37
+ var decoder = new TextDecoder();
38
+ return {
39
+ stringToBytes: function stringToBytes(s) {
40
+ return encoder.encode(s);
41
+ },
42
+ bytesToString: function bytesToString(ab) {
43
+ return decoder.decode(ab);
44
+ },
45
+ stringByteLength: function stringByteLength(s) {
46
+ return encoder.encode(s).byteLength;
47
+ }
48
+ };
49
+ }();
50
+ var FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
51
+ /**
52
+ * A machine-readable representation of the authenticity for a `ShieldState`.
53
+ */
54
+ export var ShieldStateCode;
55
+ (function (ShieldStateCode) {
56
+ /**
57
+ * Not enough information available to check the authenticity.
58
+ */
59
+ ShieldStateCode[ShieldStateCode["AuthenticityNotGuaranteed"] = 0] = "AuthenticityNotGuaranteed";
60
+ /**
61
+ * The sending device isn't yet known by the Client.
62
+ */
63
+ ShieldStateCode[ShieldStateCode["UnknownDevice"] = 1] = "UnknownDevice";
64
+ /**
65
+ * The sending device hasn't been verified by the sender.
66
+ */
67
+ ShieldStateCode[ShieldStateCode["UnsignedDevice"] = 2] = "UnsignedDevice";
68
+ /**
69
+ * The sender hasn't been verified by the Client's user.
70
+ */
71
+ ShieldStateCode[ShieldStateCode["UnverifiedIdentity"] = 3] = "UnverifiedIdentity";
72
+ /**
73
+ * An unencrypted event in an encrypted room.
74
+ */
75
+ ShieldStateCode[ShieldStateCode["SentInClear"] = 4] = "SentInClear";
76
+ /**
77
+ * The sender was previously verified but changed their identity.
78
+ */
79
+ ShieldStateCode[ShieldStateCode["VerificationViolation"] = 5] = "VerificationViolation";
80
+ /**
81
+ * The `sender` field on the event does not match the owner of the device
82
+ * that established the Megolm session.
83
+ */
84
+ ShieldStateCode[ShieldStateCode["MismatchedSender"] = 6] = "MismatchedSender";
85
+ })(ShieldStateCode || (ShieldStateCode = {}));
86
+ var FfiConverterTypeShieldStateCode = function () {
87
+ var ordinalConverter = FfiConverterInt32;
88
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter) {
89
+ function FFIConverter() {
90
+ _classCallCheck(this, FFIConverter);
91
+ return _callSuper(this, FFIConverter, arguments);
92
+ }
93
+ _inherits(FFIConverter, _AbstractFfiConverter);
94
+ return _createClass(FFIConverter, [{
95
+ key: "read",
96
+ value: function read(from) {
97
+ switch (ordinalConverter.read(from)) {
98
+ case 1:
99
+ return ShieldStateCode.AuthenticityNotGuaranteed;
100
+ case 2:
101
+ return ShieldStateCode.UnknownDevice;
102
+ case 3:
103
+ return ShieldStateCode.UnsignedDevice;
104
+ case 4:
105
+ return ShieldStateCode.UnverifiedIdentity;
106
+ case 5:
107
+ return ShieldStateCode.SentInClear;
108
+ case 6:
109
+ return ShieldStateCode.VerificationViolation;
110
+ case 7:
111
+ return ShieldStateCode.MismatchedSender;
112
+ default:
113
+ throw new UniffiInternalError.UnexpectedEnumCase();
114
+ }
115
+ }
116
+ }, {
117
+ key: "write",
118
+ value: function write(value, into) {
119
+ switch (value) {
120
+ case ShieldStateCode.AuthenticityNotGuaranteed:
121
+ return ordinalConverter.write(1, into);
122
+ case ShieldStateCode.UnknownDevice:
123
+ return ordinalConverter.write(2, into);
124
+ case ShieldStateCode.UnsignedDevice:
125
+ return ordinalConverter.write(3, into);
126
+ case ShieldStateCode.UnverifiedIdentity:
127
+ return ordinalConverter.write(4, into);
128
+ case ShieldStateCode.SentInClear:
129
+ return ordinalConverter.write(5, into);
130
+ case ShieldStateCode.VerificationViolation:
131
+ return ordinalConverter.write(6, into);
132
+ case ShieldStateCode.MismatchedSender:
133
+ return ordinalConverter.write(7, into);
134
+ }
135
+ }
136
+ }, {
137
+ key: "allocationSize",
138
+ value: function allocationSize(value) {
139
+ return ordinalConverter.allocationSize(0);
140
+ }
141
+ }]);
142
+ }(AbstractFfiConverterByteArray);
143
+ return new FFIConverter();
144
+ }();
145
+ /**
146
+ * This should be called before anything else.
147
+ *
148
+ * It is likely that this is being done for you by the library's `index.ts`.
149
+ *
150
+ * It checks versions of uniffi between when the Rust scaffolding was generated
151
+ * and when the bindings were generated.
152
+ *
153
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
154
+ */
155
+ function uniffiEnsureInitialized() {
156
+ // Get the bindings contract version from our ComponentInterface
157
+ var bindingsContractVersion = 29;
158
+ // Get the scaffolding contract version by calling the into the dylib
159
+ var scaffoldingContractVersion = nativeModule().ubrn_ffi_matrix_sdk_common_uniffi_contract_version();
160
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
161
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
162
+ }
163
+ }
164
+ export default Object.freeze({
165
+ initialize: uniffiEnsureInitialized,
166
+ converters: {
167
+ FfiConverterTypeShieldStateCode: FfiConverterTypeShieldStateCode
168
+ }
169
+ });