1#![allow(non_camel_case_types)] use std::fmt;
4use std::ffi::NulError;
5
6#[derive(Debug)]
7#[derive(PartialEq)]
8#[repr(i32)]
9pub enum LexActivatorStatus {
10 LA_OK = 0,
12 LA_FAIL = 1,
14 LA_EXPIRED = 20,
16 LA_SUSPENDED =21,
18 LA_GRACE_PERIOD_OVER = 22,
20 LA_TRIAL_EXPIRED = 25,
22 LA_LOCAL_TRIAL_EXPIRED = 26,
24 LA_RELEASE_UPDATE_AVAILABLE = 30,
26 LA_RELEASE_UPDATE_NOT_AVAILABLE = 31,
28 LA_RELEASE_UPDATE_AVAILABLE_NOT_ALLOWED = 32,
30}
31
32#[derive(Debug)]
33#[derive(PartialEq)]
34#[repr(i32)]
35pub enum LexActivatorError {
36 LA_FAIL = 1,
38 LA_E_FILE_PATH = 40,
40 LA_E_PRODUCT_FILE = 41,
42 LA_E_PRODUCT_DATA = 42,
44 LA_E_PRODUCT_ID = 43,
46 LA_E_SYSTEM_PERMISSION = 44,
48 LA_E_FILE_PERMISSION = 45,
50 LA_E_WMIC = 46,
52 LA_E_TIME = 47,
54 LA_E_INET = 48,
56 LA_E_NET_PROXY = 49,
58 LA_E_HOST_URL = 50,
60 LA_E_BUFFER_SIZE = 51,
62 LA_E_APP_VERSION_LENGTH = 52,
64 LA_E_REVOKED = 53,
66 LA_E_LICENSE_KEY = 54,
68 LA_E_LICENSE_TYPE = 55,
70 LA_E_OFFLINE_RESPONSE_FILE = 56,
72 LA_E_OFFLINE_RESPONSE_FILE_EXPIRED = 57,
74 LA_E_ACTIVATION_LIMIT = 58,
76 LA_E_ACTIVATION_NOT_FOUND = 59,
78 LA_E_DEACTIVATION_LIMIT = 60,
80 LA_E_TRIAL_NOT_ALLOWED = 61,
82 LA_E_TRIAL_ACTIVATION_LIMIT = 62,
84 LA_E_MACHINE_FINGERPRINT = 63,
86 LA_E_METADATA_KEY_LENGTH = 64,
88 LA_E_METADATA_VALUE_LENGTH = 65,
90 LA_E_ACTIVATION_METADATA_LIMIT = 66,
92 LA_E_TRIAL_ACTIVATION_METADATA_LIMIT = 67,
94 LA_E_METADATA_KEY_NOT_FOUND = 68,
96 LA_E_TIME_MODIFIED = 69,
98 LA_E_RELEASE_VERSION_FORMAT = 70,
100 LA_E_AUTHENTICATION_FAILED = 71,
102 LA_E_METER_ATTRIBUTE_NOT_FOUND = 72,
104 LA_E_METER_ATTRIBUTE_USES_LIMIT_REACHED = 73,
106 LA_E_CUSTOM_FINGERPRINT_LENGTH = 74,
108 LA_E_PRODUCT_VERSION_NOT_LINKED = 75,
110 LA_E_FEATURE_FLAG_NOT_FOUND = 76,
112 LA_E_RELEASE_VERSION_NOT_ALLOWED = 77,
114 LA_E_RELEASE_PLATFORM_LENGTH = 78,
116 LA_E_RELEASE_CHANNEL_LENGTH = 79,
118 LA_E_VM = 80,
120 LA_E_COUNTRY = 81,
122 LA_E_IP = 82,
124 LA_E_CONTAINER = 83,
126 LA_E_RELEASE_VERSION = 84,
128 LA_E_RELEASE_PLATFORM = 85,
130 LA_E_RELEASE_CHANNEL = 86,
132 LA_E_USER_NOT_AUTHENTICATED = 87,
134 LA_E_TWO_FACTOR_AUTHENTICATION_CODE_MISSING = 88,
136 LA_E_TWO_FACTOR_AUTHENTICATION_CODE_INVALID = 89,
138 LA_E_RATE_LIMIT = 90,
140 LA_E_SERVER = 91,
142 LA_E_CLIENT = 92,
144 LA_E_LOGIN_TEMPORARILY_LOCKED = 100,
146 LA_E_AUTHENTICATION_ID_TOKEN_INVALID = 101,
148 LA_E_OIDC_SSO_NOT_ENABLED = 102,
150 LA_E_USERS_LIMIT_REACHED = 103,
152 LA_E_OS_USER = 104,
154 LA_E_INVALID_PERMISSION_FLAG = 105,
156 LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED = 106,
158}
159
160impl From<i32> for LexActivatorStatus {
161 fn from(code: i32) -> Self {
162 match code {
163 0 => LexActivatorStatus::LA_OK,
164 1 => LexActivatorStatus::LA_FAIL,
165 20 => LexActivatorStatus::LA_EXPIRED,
166 21 => LexActivatorStatus::LA_SUSPENDED,
167 22 => LexActivatorStatus::LA_GRACE_PERIOD_OVER,
168 25 => LexActivatorStatus::LA_TRIAL_EXPIRED,
169 26 => LexActivatorStatus::LA_LOCAL_TRIAL_EXPIRED,
170 30 => LexActivatorStatus::LA_RELEASE_UPDATE_AVAILABLE,
171 31 => LexActivatorStatus::LA_RELEASE_UPDATE_NOT_AVAILABLE,
172 32 => LexActivatorStatus::LA_RELEASE_UPDATE_AVAILABLE_NOT_ALLOWED,
173 _ => todo!(),
174 }
175 }
176}
177
178impl From<i32> for LexActivatorError {
179 fn from(code: i32) -> Self {
180 match code {
181 1 => LexActivatorError::LA_FAIL,
182 40 => LexActivatorError::LA_E_FILE_PATH,
183 41 => LexActivatorError::LA_E_PRODUCT_FILE,
184 42 => LexActivatorError::LA_E_PRODUCT_DATA,
185 43 => LexActivatorError::LA_E_PRODUCT_ID,
186 44 => LexActivatorError::LA_E_SYSTEM_PERMISSION,
187 45 => LexActivatorError::LA_E_FILE_PERMISSION,
188 46 => LexActivatorError::LA_E_WMIC,
189 47 => LexActivatorError::LA_E_TIME,
190 48 => LexActivatorError::LA_E_INET,
191 49 => LexActivatorError::LA_E_NET_PROXY,
192 50 => LexActivatorError::LA_E_HOST_URL,
193 51 => LexActivatorError::LA_E_BUFFER_SIZE,
194 52 => LexActivatorError::LA_E_APP_VERSION_LENGTH,
195 53 => LexActivatorError::LA_E_REVOKED,
196 54 => LexActivatorError::LA_E_LICENSE_KEY,
197 55 => LexActivatorError::LA_E_LICENSE_TYPE,
198 56 => LexActivatorError::LA_E_OFFLINE_RESPONSE_FILE,
199 57 => LexActivatorError::LA_E_OFFLINE_RESPONSE_FILE_EXPIRED,
200 58 => LexActivatorError::LA_E_ACTIVATION_LIMIT,
201 59 => LexActivatorError::LA_E_ACTIVATION_NOT_FOUND,
202 60 => LexActivatorError::LA_E_DEACTIVATION_LIMIT,
203 61 => LexActivatorError::LA_E_TRIAL_NOT_ALLOWED,
204 62 => LexActivatorError::LA_E_TRIAL_ACTIVATION_LIMIT,
205 63 => LexActivatorError::LA_E_MACHINE_FINGERPRINT,
206 64 => LexActivatorError::LA_E_METADATA_KEY_LENGTH,
207 65 => LexActivatorError::LA_E_METADATA_VALUE_LENGTH,
208 66 => LexActivatorError::LA_E_ACTIVATION_METADATA_LIMIT,
209 67 => LexActivatorError::LA_E_TRIAL_ACTIVATION_METADATA_LIMIT,
210 68 => LexActivatorError::LA_E_METADATA_KEY_NOT_FOUND,
211 69 => LexActivatorError::LA_E_TIME_MODIFIED,
212 70 => LexActivatorError::LA_E_RELEASE_VERSION_FORMAT,
213 71 => LexActivatorError::LA_E_AUTHENTICATION_FAILED,
214 72 => LexActivatorError::LA_E_METER_ATTRIBUTE_NOT_FOUND,
215 73 => LexActivatorError::LA_E_METER_ATTRIBUTE_USES_LIMIT_REACHED,
216 74 => LexActivatorError::LA_E_CUSTOM_FINGERPRINT_LENGTH,
217 75 => LexActivatorError::LA_E_PRODUCT_VERSION_NOT_LINKED,
218 76 => LexActivatorError::LA_E_FEATURE_FLAG_NOT_FOUND,
219 77 => LexActivatorError::LA_E_RELEASE_VERSION_NOT_ALLOWED,
220 78 => LexActivatorError::LA_E_RELEASE_PLATFORM_LENGTH,
221 79 => LexActivatorError::LA_E_RELEASE_CHANNEL_LENGTH,
222 80 => LexActivatorError::LA_E_VM,
223 81 => LexActivatorError::LA_E_COUNTRY,
224 82 => LexActivatorError::LA_E_IP,
225 83 => LexActivatorError::LA_E_CONTAINER,
226 84 => LexActivatorError::LA_E_RELEASE_VERSION,
227 85 => LexActivatorError::LA_E_RELEASE_PLATFORM,
228 86 => LexActivatorError::LA_E_RELEASE_CHANNEL,
229 87 => LexActivatorError::LA_E_USER_NOT_AUTHENTICATED,
230 88 => LexActivatorError::LA_E_TWO_FACTOR_AUTHENTICATION_CODE_MISSING,
231 89 => LexActivatorError::LA_E_TWO_FACTOR_AUTHENTICATION_CODE_INVALID,
232 90 => LexActivatorError::LA_E_RATE_LIMIT,
233 91 => LexActivatorError::LA_E_SERVER,
234 92 => LexActivatorError::LA_E_CLIENT,
235 100 => LexActivatorError::LA_E_LOGIN_TEMPORARILY_LOCKED,
236 101 => LexActivatorError::LA_E_AUTHENTICATION_ID_TOKEN_INVALID,
237 102 => LexActivatorError::LA_E_OIDC_SSO_NOT_ENABLED,
238 103 => LexActivatorError::LA_E_USERS_LIMIT_REACHED,
239 104 => LexActivatorError::LA_E_OS_USER,
240 105 => LexActivatorError::LA_E_INVALID_PERMISSION_FLAG,
241 106 => LexActivatorError::LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED,
242 _ => todo!(),
243 }
245 }
246}
247
248impl fmt::Display for LexActivatorStatus {
249 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
250 match self {
251 LexActivatorStatus::LA_OK => write!(f, "{} Success code.", LexActivatorStatus::LA_OK as i32),
252 LexActivatorStatus::LA_FAIL => write!(f, "{} Failure code.", LexActivatorStatus::LA_FAIL as i32),
253 LexActivatorStatus::LA_EXPIRED => write!(f, "{} The license has expired or system time has been tampered with. Ensure your date and time settings are correct.", LexActivatorStatus::LA_EXPIRED as i32),
254 LexActivatorStatus::LA_SUSPENDED => write!(f, "{} The license has been suspended.", LexActivatorStatus::LA_SUSPENDED as i32),
255 LexActivatorStatus::LA_GRACE_PERIOD_OVER => write!(f, "{} The grace period for server sync is over.", LexActivatorStatus::LA_GRACE_PERIOD_OVER as i32),
256 LexActivatorStatus::LA_TRIAL_EXPIRED => write!(f, "{} The trial has expired or system time has been tampered with. Ensure your date and time settings are correct.", LexActivatorStatus::LA_TRIAL_EXPIRED as i32),
257 LexActivatorStatus::LA_LOCAL_TRIAL_EXPIRED => write!(f, "{} The local trial has expired or system time has been tampered with. Ensure your date and time settings are correct.", LexActivatorStatus::LA_LOCAL_TRIAL_EXPIRED as i32),
258 LexActivatorStatus::LA_RELEASE_UPDATE_AVAILABLE => write!(f, "{} A new update is available for the product. This means a new release has been published for the product.", LexActivatorStatus::LA_RELEASE_UPDATE_AVAILABLE as i32),
259 LexActivatorStatus::LA_RELEASE_UPDATE_NOT_AVAILABLE => write!(f, "{} No new update is available for the product. The current version is latest.", LexActivatorStatus::LA_RELEASE_UPDATE_NOT_AVAILABLE as i32),
260 LexActivatorStatus::LA_RELEASE_UPDATE_AVAILABLE_NOT_ALLOWED => write!(f, "{} The update available is not allowed for this license.", LexActivatorStatus::LA_RELEASE_UPDATE_AVAILABLE_NOT_ALLOWED as i32),
261 }
262 }
263}
264
265impl fmt::Display for LexActivatorError {
266 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
267 match self {
268 LexActivatorError::LA_FAIL => write!(f, "{} Failure code.", LexActivatorError::LA_FAIL as i32),
269 LexActivatorError::LA_E_FILE_PATH => write!(f, "{} Invalid file path.", LexActivatorError::LA_E_FILE_PATH as i32),
270 LexActivatorError::LA_E_PRODUCT_FILE => write!(f, "{} Invalid or corrupted product file.", LexActivatorError::LA_E_PRODUCT_FILE as i32),
271 LexActivatorError::LA_E_PRODUCT_DATA => write!(f, "{} Invalid product data.", LexActivatorError::LA_E_PRODUCT_DATA as i32),
272 LexActivatorError::LA_E_PRODUCT_ID => write!(f, "{} The product id is incorrect.", LexActivatorError::LA_E_PRODUCT_ID as i32),
273 LexActivatorError::LA_E_SYSTEM_PERMISSION => write!(f, "{} Insufficent system permissions.", LexActivatorError::LA_E_SYSTEM_PERMISSION as i32),
274 LexActivatorError::LA_E_FILE_PERMISSION => write!(f, "{} No permission to write to file.", LexActivatorError::LA_E_FILE_PERMISSION as i32),
275 LexActivatorError::LA_E_WMIC => write!(f, "{} Fingerprint couldn't be generated because Windows Management Instrumentation (WMI) service has been disabled.", LexActivatorError::LA_E_WMIC as i32),
276 LexActivatorError::LA_E_TIME => write!(f, "{} The difference between the network time and the system time is more than allowed clock offset.", LexActivatorError::LA_E_TIME as i32),
277 LexActivatorError::LA_E_INET => write!(f, "{} Failed to connect to the server due to network error.", LexActivatorError::LA_E_INET as i32),
278 LexActivatorError::LA_E_NET_PROXY => write!(f, "{} Invalid network proxy.", LexActivatorError::LA_E_NET_PROXY as i32),
279 LexActivatorError::LA_E_HOST_URL => write!(f, "{} Invalid Cryptlex host url.", LexActivatorError::LA_E_HOST_URL as i32),
280 LexActivatorError::LA_E_BUFFER_SIZE => write!(f, "{} The buffer size was smaller than required.", LexActivatorError::LA_E_BUFFER_SIZE as i32),
281 LexActivatorError::LA_E_APP_VERSION_LENGTH => write!(f, "{} App version length is more than characters.", LexActivatorError::LA_E_APP_VERSION_LENGTH as i32),
282 LexActivatorError::LA_E_REVOKED => write!(f, "{} The license has been revoked.", LexActivatorError::LA_E_REVOKED as i32),
283 LexActivatorError::LA_E_LICENSE_KEY => write!(f, "{} Invalid license key.", LexActivatorError::LA_E_LICENSE_KEY as i32),
284 LexActivatorError::LA_E_LICENSE_TYPE => write!(f, "{} Invalid license type. Make sure floating license is not being used.", LexActivatorError::LA_E_LICENSE_TYPE as i32),
285 LexActivatorError::LA_E_OFFLINE_RESPONSE_FILE => write!(f, "{} Invalid offline activation response file.", LexActivatorError::LA_E_OFFLINE_RESPONSE_FILE as i32),
286 LexActivatorError::LA_E_OFFLINE_RESPONSE_FILE_EXPIRED => write!(f, "{} The offline activation response has expired.", LexActivatorError::LA_E_OFFLINE_RESPONSE_FILE_EXPIRED as i32),
287 LexActivatorError::LA_E_ACTIVATION_LIMIT => write!(f, "{} The license has reached it's allowed activations limit.", LexActivatorError::LA_E_ACTIVATION_LIMIT as i32),
288 LexActivatorError::LA_E_ACTIVATION_NOT_FOUND => write!(f, "{} The license activation was deleted on the server.", LexActivatorError::LA_E_ACTIVATION_NOT_FOUND as i32),
289 LexActivatorError::LA_E_DEACTIVATION_LIMIT => write!(f, "{} The license has reached it's allowed deactivations limit.", LexActivatorError::LA_E_DEACTIVATION_LIMIT as i32),
290 LexActivatorError::LA_E_TRIAL_NOT_ALLOWED => write!(f, "{} Trial not allowed for the product.", LexActivatorError::LA_E_TRIAL_NOT_ALLOWED as i32),
291 LexActivatorError::LA_E_TRIAL_ACTIVATION_LIMIT => write!(f, "{} Your account has reached it's trial activations limit and trial not allowed for the product.", LexActivatorError::LA_E_TRIAL_ACTIVATION_LIMIT as i32),
292 LexActivatorError::LA_E_MACHINE_FINGERPRINT => write!(f, "{} Machine fingerprint has changed since activation.", LexActivatorError::LA_E_MACHINE_FINGERPRINT as i32),
293 LexActivatorError::LA_E_METADATA_KEY_LENGTH => write!(f, "{} Metadata key length is more than 256 characters.", LexActivatorError::LA_E_METADATA_KEY_LENGTH as i32),
294 LexActivatorError::LA_E_METADATA_VALUE_LENGTH => write!(f, "{} Metadata value length is more than 256 characters.", LexActivatorError::LA_E_METADATA_VALUE_LENGTH as i32),
295 LexActivatorError::LA_E_ACTIVATION_METADATA_LIMIT => write!(f, "{} The license has reached it's metadata fields limit.", LexActivatorError::LA_E_ACTIVATION_METADATA_LIMIT as i32),
296 LexActivatorError::LA_E_TRIAL_ACTIVATION_METADATA_LIMIT => write!(f, "{} The trial has reached it's metadata fields limit.", LexActivatorError::LA_E_TRIAL_ACTIVATION_METADATA_LIMIT as i32),
297 LexActivatorError::LA_E_METADATA_KEY_NOT_FOUND => write!(f, "{} The metadata key does not exist.", LexActivatorError::LA_E_METADATA_KEY_NOT_FOUND as i32),
298 LexActivatorError::LA_E_TIME_MODIFIED => write!(f, "{} The system time has been tampered (backdated).", LexActivatorError::LA_E_TIME_MODIFIED as i32),
299 LexActivatorError::LA_E_RELEASE_VERSION_FORMAT => write!(f, "{} Invalid version format.", LexActivatorError::LA_E_RELEASE_VERSION_FORMAT as i32),
300 LexActivatorError::LA_E_AUTHENTICATION_FAILED => write!(f, "{} Incorrect email or password.", LexActivatorError::LA_E_AUTHENTICATION_FAILED as i32),
301 LexActivatorError::LA_E_METER_ATTRIBUTE_NOT_FOUND => write!(f, "{} The meter attribute does not exist.", LexActivatorError::LA_E_METER_ATTRIBUTE_NOT_FOUND as i32),
302 LexActivatorError::LA_E_METER_ATTRIBUTE_USES_LIMIT_REACHED => write!(f, "{} The meter attribute has reached it's usage limit.", LexActivatorError::LA_E_METER_ATTRIBUTE_USES_LIMIT_REACHED as i32),
303 LexActivatorError::LA_E_CUSTOM_FINGERPRINT_LENGTH => write!(f, "{} Custom device fingerprint length is less than 64 characters or more than 256 characters.", LexActivatorError::LA_E_CUSTOM_FINGERPRINT_LENGTH as i32),
304 LexActivatorError::LA_E_PRODUCT_VERSION_NOT_LINKED => write!(f, "{} No product version is linked with the license.", LexActivatorError::LA_E_PRODUCT_VERSION_NOT_LINKED as i32),
305 LexActivatorError::LA_E_FEATURE_FLAG_NOT_FOUND => write!(f, "{} The product version feature flag does not exist.", LexActivatorError::LA_E_FEATURE_FLAG_NOT_FOUND as i32),
306 LexActivatorError::LA_E_RELEASE_VERSION_NOT_ALLOWED => write!(f, "{} The release version is not allowed.", LexActivatorError::LA_E_RELEASE_VERSION_NOT_ALLOWED as i32),
307 LexActivatorError::LA_E_RELEASE_PLATFORM_LENGTH => write!(f, "{} Release platform length is more than 256 characters.", LexActivatorError::LA_E_RELEASE_PLATFORM_LENGTH as i32),
308 LexActivatorError::LA_E_RELEASE_CHANNEL_LENGTH => write!(f, "{} Release channel length is more than 256 characters.", LexActivatorError::LA_E_RELEASE_CHANNEL_LENGTH as i32),
309 LexActivatorError::LA_E_VM => write!(f, "{} Application is running inside virtual machine / hypervisor and activation has been disallowed in the VM.", LexActivatorError::LA_E_VM as i32),
310 LexActivatorError::LA_E_COUNTRY => write!(f, "{} Country is not allowed.", LexActivatorError::LA_E_COUNTRY as i32),
311 LexActivatorError::LA_E_IP => write!(f, "{} IP address is not allowed.", LexActivatorError::LA_E_IP as i32),
312 LexActivatorError::LA_E_CONTAINER => write!(f, "{} Application is being run inside a container and activation has been disallowed in the container.", LexActivatorError::LA_E_CONTAINER as i32),
313 LexActivatorError::LA_E_RELEASE_VERSION => write!(f, "{} Invalid release version. Make sure the release version uses the following formats: x.x, x.x.x, x.x.x.x (where x is a number).", LexActivatorError::LA_E_RELEASE_VERSION as i32),
314 LexActivatorError::LA_E_RELEASE_PLATFORM => write!(f, "{} Release platform not set.", LexActivatorError::LA_E_RELEASE_PLATFORM as i32),
315 LexActivatorError::LA_E_RELEASE_CHANNEL => write!(f, "{} Release channel not set.", LexActivatorError::LA_E_RELEASE_CHANNEL as i32),
316 LexActivatorError::LA_E_USER_NOT_AUTHENTICATED => write!(f, "{} The user is not authenticated.", LexActivatorError::LA_E_USER_NOT_AUTHENTICATED as i32),
317 LexActivatorError::LA_E_TWO_FACTOR_AUTHENTICATION_CODE_MISSING => write!(f, "{} The two-factor authentication code for the user authentication is missing.", LexActivatorError::LA_E_TWO_FACTOR_AUTHENTICATION_CODE_MISSING as i32),
318 LexActivatorError::LA_E_TWO_FACTOR_AUTHENTICATION_CODE_INVALID => write!(f, "{} he two-factor authentication code provided by the user is invalid.", LexActivatorError::LA_E_TWO_FACTOR_AUTHENTICATION_CODE_INVALID as i32),
319 LexActivatorError::LA_E_RATE_LIMIT => write!(f, "{} Rate limit for API has reached, try again later.", LexActivatorError::LA_E_RATE_LIMIT as i32),
320 LexActivatorError::LA_E_SERVER => write!(f, "{} Server error.", LexActivatorError::LA_E_SERVER as i32),
321 LexActivatorError::LA_E_CLIENT => write!(f, "{} Client error.", LexActivatorError::LA_E_CLIENT as i32),
322 LexActivatorError::LA_E_LOGIN_TEMPORARILY_LOCKED => write!(f, "{} The user account has been temporarily locked for 5 mins due to 5 failed attempts.", LexActivatorError::LA_E_LOGIN_TEMPORARILY_LOCKED as i32),
323 LexActivatorError::LA_E_AUTHENTICATION_ID_TOKEN_INVALID => write!(f, "{} Invalid authentication ID token.", LexActivatorError::LA_E_AUTHENTICATION_ID_TOKEN_INVALID as i32),
324 LexActivatorError::LA_E_OIDC_SSO_NOT_ENABLED => write!(f, "{} OIDC SSO is not enabled.", LexActivatorError::LA_E_OIDC_SSO_NOT_ENABLED as i32),
325 LexActivatorError::LA_E_USERS_LIMIT_REACHED => write!(f, "{} The allowed users for this account has reached its limit.", LexActivatorError::LA_E_USERS_LIMIT_REACHED as i32),
326 LexActivatorError::LA_E_OS_USER => write!(f, "{} OS user has changed since activation and the license is user-locked.", LexActivatorError::LA_E_OS_USER as i32),
327 LexActivatorError::LA_E_INVALID_PERMISSION_FLAG => write!(f, "{} Invalid permission flag.", LexActivatorError::LA_E_INVALID_PERMISSION_FLAG as i32),
328 LexActivatorError::LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED => write!(f, "{} The free plan has reached its activation limit.", LexActivatorError::LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED as i32),
329 }
330 }
331}
332
333impl From<NulError> for LexActivatorError {
334 fn from(_: NulError) -> Self {
335 LexActivatorError::LA_E_CLIENT
336 }
337}
338
339#[derive(Debug)]
340#[repr(i32)]
341pub enum LexActivatorCode {
342 Status(LexActivatorStatus),
343 Error(LexActivatorError),
344}
345
346impl LexActivatorCode {
347 pub fn from_i32(code: i32) -> Self {
348 match code {
349 0..=32 => LexActivatorCode::Status(LexActivatorStatus::from(code)),
350 40..=106 => LexActivatorCode::Error(LexActivatorError::from(code)),
351 _ => LexActivatorCode::Error(LexActivatorError::LA_E_CLIENT), }
353 }
354}