TaggedMessage

- Added documentation for fields `tag` and `data`
- Added documentation for both constructors
- Added documentation for `getPayload()`, `getTag()`, `setPayload(byte[])` and `setTag(ulong)`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-27 16:20:26 +02:00
parent cd0eed6dda
commit 6b04a0325a

View File

@ -10,15 +10,32 @@ module tristanable.encoding;
*/ */
public final class TaggedMessage public final class TaggedMessage
{ {
/**
* This message's tag
*/
private ulong tag; private ulong tag;
/**
* The payload
*/
private byte[] data; private byte[] data;
/**
* Constructs a new TaggedMessage with the given tag and payload
*
* Params:
* tag = the tag to use
* data = the payload
*/
this(ulong tag, byte[] data) this(ulong tag, byte[] data)
{ {
this.tag = tag; this.tag = tag;
this.data = data; this.data = data;
} }
/**
* Parameterless constructor used for decoder
*/
private this() {} private this() {}
/** /**
@ -126,21 +143,43 @@ public final class TaggedMessage
return encodedMessage; return encodedMessage;
} }
/**
* Get the message's payload
*
* Returns: the payload
*/
public byte[] getPayload() public byte[] getPayload()
{ {
return data; return data;
} }
/**
* Get the message's tag
*
* Returns: the tag
*/
public ulong getTag() public ulong getTag()
{ {
return tag; return tag;
} }
/**
* Set the message's payload
*
* Params:
* newPayload = the payload to use
*/
public void setPayload(byte[] newPayload) public void setPayload(byte[] newPayload)
{ {
this.data = newPayload; this.data = newPayload;
} }
/**
* Set the message's tag
*
* Params:
* newTag = the tag to use
*/
public void setTag(ulong newTag) public void setTag(ulong newTag)
{ {
this.tag = newTag; this.tag = newTag;