44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
/**
|
|
* @typedef {Object} LoginResponse the response from a login request
|
|
* @property boolean logical login was successful or not
|
|
*/
|
|
class LoginResponse {
|
|
/**
|
|
* login was successful or not
|
|
* @return {boolean} gets the value of success
|
|
*/
|
|
get success() {
|
|
return this._data.getboolean(0, true);
|
|
}
|
|
/**
|
|
* login was successful or not
|
|
* @param {boolean} sets the value of success
|
|
*/
|
|
set success(v) {
|
|
return this._data.setboolean(0, v, true);
|
|
}
|
|
/**
|
|
* Get the struct representation of the object
|
|
* @return {Uint8Array} u8 array of the C struct.
|
|
*/
|
|
get bytes() {
|
|
return new Uint8Array(this._ptr);
|
|
}
|
|
/**
|
|
* Constructs a new LoginResponse
|
|
*
|
|
* @param {{success: boolean, }} init The arguments to construct the object.
|
|
* @param {ArrayBuffer} ptr The pointer to the C struct.
|
|
*/
|
|
constructor(init = {}, ptr = undefined) {
|
|
this._size = 1;
|
|
this._ptr = ptr?.buffer || new ArrayBuffer(this._size);
|
|
this._data = new DataView(this._ptr);
|
|
|
|
for (const key of Object.keys(init)) {
|
|
this[key] = init[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
export default LoginResponse |