From ee7a1e05be5cd7d46624bbfeb68603c14b650d2d Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sat, 30 Sep 2023 14:00:01 +0000 Subject: [PATCH] build based on 2c1766f --- dev/.documenter-siteinfo.json | 2 +- dev/api.html | 12 ++++++------ dev/index.html | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index ed52a7b..2567ba7 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2023-09-30T13:25:14","documenter_version":"1.1.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2023-09-30T13:59:56","documenter_version":"1.1.0"}} \ No newline at end of file diff --git a/dev/api.html b/dev/api.html index 17563a8..eaf965e 100644 --- a/dev/api.html +++ b/dev/api.html @@ -1,22 +1,22 @@ -API Reference · ProtocolDataUnits.jl

API Reference

ProtocolDataUnits.byteorderFunction
byteorder(::Type{T})

Byte order used for PDUs of type T. Defaults to BIG_ENDIAN. To change byte order, define a method for this function.

Example:

ProtocolDataUnits.byteorder(::Type{MyPDU}) = LITTLE_ENDIAN
source
byteorder(::Type{T}, ::Val{s})

Byte order used for PDUs of type T for field s. Defaults to the same byte order as the PDU. To change byte order, define a method for this function.

Example:

ProtocolDataUnits.byteorder(::Type{MyPDU}, ::Val{:myfield}) = LITTLE_ENDIAN
source
Base.lengthMethod
length(::Type{T}, ::Val{s}, info::PDUInfo)

Length of field s in PDU of type T. Defaults to nothing, which indicates that the length is not known, and wire-encoding is used to store length as part of PDU. The length is specified in number of elements for vectors, and number of bytes for strings.

Examples:

# length of field x is 4 bytes less than length of PDU
+API Reference · ProtocolDataUnits.jl

API Reference

ProtocolDataUnits.byteorderFunction
byteorder(::Type{T})

Byte order used for PDUs of type T. Defaults to BIG_ENDIAN. To change byte order, define a method for this function.

Example:

ProtocolDataUnits.byteorder(::Type{MyPDU}) = LITTLE_ENDIAN
source
byteorder(::Type{T}, ::Val{s})

Byte order used for PDUs of type T for field s. Defaults to the same byte order as the PDU. To change byte order, define a method for this function.

Example:

ProtocolDataUnits.byteorder(::Type{MyPDU}, ::Val{:myfield}) = LITTLE_ENDIAN
source
Base.lengthMethod
length(::Type{T}, ::Val{s}, info::PDUInfo)

Length of field s in PDU of type T. Defaults to nothing, which indicates that the length is not known, and wire-encoding is used to store length as part of PDU. The length is specified in number of elements for vectors, and number of bytes for strings.

Examples:

# length of field x is 4 bytes less than length of PDU
 Base.length(::Type{MyPDU}, ::Val{:x}, info) = info.length - 4
 
 # length of field x is given by the value of field n in the PDU
-Base.length(::Type{MyPDU}, ::Val{:x}, info) = info.get(:n)
source
ProtocolDataUnits.fieldtypeFunction
fieldtype(::Type{T}, ::Val{s}, info::PDUInfo)

Concrete type of field s in PDU of type T. Defaults to the type of the field in the PDU. To specialize the type based on auxillary information in the PDU, define a method for this function.

Example:

# field x::Union{Int32,Int64} is Int32 if xtype is 4, Int64 otherwise
-ProtocolDataUnits.fieldtype(::Type{MyPDU}, ::Val{:x}, info) = info.get(:xtype) == 4 ? Int32 : Int64
source
ProtocolDataUnits.PDUInfoType

PDU information with fields:

  • length: length of PDU in bytes, if known, missing otherwise
  • get: function that returns value of field s in the PDU
source
Base.readMethod
read(io::IO, T::PDU; hooks=true)
-read(io::IO, T::PDU; nbytes, hooks=true)

Decodes a vector of bytes from stream io to give a PDU. If nbytes is specified, the PDU is assumed to be of length nbytes bytes. If hooks is true, the post-decode hook is called after decoding the PDU.

source
Base.writeMethod
write(io::IO, pdu::PDU; hooks=true)

Encodes a PDU into a vector of bytes written to stream io. If hooks is true, the pre-encode hook is called before encoding the PDU.

source
Base.VectorMethod
Vector{UInt8}(pdu::PDU; hooks=true)

Encodes a PDU into a vector of bytes. If hooks is true, the pre-encode hook is called before encoding the PDU.

source
ProtocolDataUnits.preencodeFunction
preencode(pdu::PDU)

Pre-encode hook. This function is called before encoding a PDU into a vector of bytes. It may return a new PDU, which is then encoded instead of the original PDU. The pre-encode hook should not change the type of the PDU.

Example:

using Accessors, CRC32
+Base.length(::Type{MyPDU}, ::Val{:x}, info) = info.get(:n)
source
ProtocolDataUnits.fieldtypeFunction
fieldtype(::Type{T}, ::Val{s}, info::PDUInfo)

Concrete type of field s in PDU of type T. Defaults to the type of the field in the PDU. To specialize the type based on auxillary information in the PDU, define a method for this function.

Example:

# field x::Union{Int32,Int64} is Int32 if xtype is 4, Int64 otherwise
+ProtocolDataUnits.fieldtype(::Type{MyPDU}, ::Val{:x}, info) = info.get(:xtype) == 4 ? Int32 : Int64
source
ProtocolDataUnits.PDUInfoType

PDU information with fields:

  • length: length of PDU in bytes, if known, missing otherwise
  • get: function that returns value of field s in the PDU
source
Base.readMethod
read(io::IO, T::PDU; hooks=true)
+read(io::IO, T::PDU; nbytes, hooks=true)

Decodes a vector of bytes from stream io to give a PDU. If nbytes is specified, the PDU is assumed to be of length nbytes bytes. If hooks is true, the post-decode hook is called after decoding the PDU.

source
Base.writeMethod
write(io::IO, pdu::PDU; hooks=true)

Encodes a PDU into a vector of bytes written to stream io. If hooks is true, the pre-encode hook is called before encoding the PDU.

source
Base.VectorMethod
Vector{UInt8}(pdu::PDU; hooks=true)

Encodes a PDU into a vector of bytes. If hooks is true, the pre-encode hook is called before encoding the PDU.

source
ProtocolDataUnits.preencodeFunction
preencode(pdu::PDU)

Pre-encode hook. This function is called before encoding a PDU into a vector of bytes. It may return a new PDU, which is then encoded instead of the original PDU. The pre-encode hook should not change the type of the PDU.

Example:

using Accessors, CRC32
 
 # assumes MyPDU has field crc::UInt32 as the last field
 function ProtocolDataUnits.preencode(pdu::MyPDU)
   bytes = Vector{UInt8}(pdu; hooks=false)
   crc = crc32(bytes[1:end-4])
   @set pdu.crc = crc
-end
source
ProtocolDataUnits.postdecodeFunction
postdecode(pdu::PDU)

Post-decode hook. This function is called after decoding a PDU from a vector of bytes. It may return a new PDU, which is then returned instead of the original PDU. The post-decode hook should not change the type of the PDU. The post-decode hook may also be used to validate the PDU, and throw an error if the PDU is invalid.

Example:

using CRC32
+end
source
ProtocolDataUnits.postdecodeFunction
postdecode(pdu::PDU)

Post-decode hook. This function is called after decoding a PDU from a vector of bytes. It may return a new PDU, which is then returned instead of the original PDU. The post-decode hook should not change the type of the PDU. The post-decode hook may also be used to validate the PDU, and throw an error if the PDU is invalid.

Example:

using CRC32
 
 # assumes MyPDU has field crc::UInt32 as the last field
 function ProtocolDataUnits.postdecode(pdu::MyPDU)
   bytes = Vector{UInt8}(pdu; hooks=false)
   pdu.crc == crc32(bytes[1:end-4]) || throw(ErrorException("CRC check failed"))
   pdu
-end
source
+end
source
diff --git a/dev/index.html b/dev/index.html index 1762ddd..a7c1fa2 100644 --- a/dev/index.html +++ b/dev/index.html @@ -255,4 +255,4 @@ @assert length(bytes) == 7 pdu2 = App2PDU(bytes) @assert pdu.hdr === nothing -@assert pdu == pdu2 +@assert pdu == pdu2