+/** An implementation of CustomMessageReader */
export interface CustomMessageReaderInterface {
+ /**Decodes a custom message to `CustomMessageType`. If the given message type is known to the
+ * implementation and the message could be decoded, must return `Ok(Some(message))`. If the
+ * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error
+ * occur, must return `Err(DecodeError::X)` where `X` details the encountered error.
+ */
read(message_type: number, buffer: Uint8Array): Result_COption_TypeZDecodeErrorZ;
}
held: CustomMessageReader;
}
+/**
+ * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers)
+ * decoders.
+ */
export class CustomMessageReader extends CommonBase {
/* @internal */
public bindings_instance?: bindings.LDKCustomMessageReader;
this.bindings_instance = null;
}
- static new_impl(arg: CustomMessageReaderInterface): CustomMessageReader {
+ /** Creates a new instance of CustomMessageReader from a given implementation */
+ public static new_impl(arg: CustomMessageReaderInterface): CustomMessageReader {
const impl_holder: LDKCustomMessageReaderHolder = new LDKCustomMessageReaderHolder();
let structImplementation = {
read (message_type: number, buffer: number): number {
impl_holder.held.bindings_instance = structImplementation;
return impl_holder.held;
}
+
+ /**
+ * Decodes a custom message to `CustomMessageType`. If the given message type is known to the
+ * implementation and the message could be decoded, must return `Ok(Some(message))`. If the
+ * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error
+ * occur, must return `Err(DecodeError::X)` where `X` details the encountered error.
+ */
public read(message_type: number, buffer: Uint8Array): Result_COption_TypeZDecodeErrorZ {
const ret: number = bindings.CustomMessageReader_read(this.ptr, message_type, bindings.encodeUint8Array(buffer));
const ret_hu_conv: Result_COption_TypeZDecodeErrorZ = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret);