2022-09-05 16:57:11 -04:00
|
|
|
import { toUtf8Bytes, toUtf8String } from "../../utils/utf8.js";
|
|
|
|
import { Typed } from "../typed.js";
|
|
|
|
import { DynamicBytesCoder } from "./bytes.js";
|
2022-11-30 15:44:23 -05:00
|
|
|
/**
|
|
|
|
* @_ignore
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
export class StringCoder extends DynamicBytesCoder {
|
|
|
|
constructor(localName) {
|
|
|
|
super("string", localName);
|
|
|
|
}
|
|
|
|
defaultValue() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
encode(writer, _value) {
|
|
|
|
return super.encode(writer, toUtf8Bytes(Typed.dereference(_value, "string")));
|
|
|
|
}
|
|
|
|
decode(reader) {
|
|
|
|
return toUtf8String(super.decode(reader));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=string.js.map
|