mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Improve documentation comments for serde library
This commit is contained in:
parent
eac34d2e7e
commit
5167a71e6f
1 changed files with 81 additions and 30 deletions
111
types/serde.luau
111
types/serde.luau
|
@ -1,7 +1,58 @@
|
||||||
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@interface EncodeDecodeFormat
|
||||||
|
|
||||||
|
A serialization/deserialization format supported by the Serde library.
|
||||||
|
|
||||||
|
Currently supported formats:
|
||||||
|
|
||||||
|
| Name | Learn More |
|
||||||
|
|:-------|:---------------------|
|
||||||
|
| `json` | https://www.json.org |
|
||||||
|
| `yaml` | https://yaml.org |
|
||||||
|
| `toml` | https://toml.io |
|
||||||
|
]=]
|
||||||
export type EncodeDecodeFormat = "json" | "yaml" | "toml"
|
export type EncodeDecodeFormat = "json" | "yaml" | "toml"
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@interface CompressDecompressFormat
|
||||||
|
|
||||||
|
A compression/decompression format supported by the Serde library.
|
||||||
|
|
||||||
|
Currently supported formats:
|
||||||
|
|
||||||
|
| Name | Learn More |
|
||||||
|
|:---------|:----------------------------------|
|
||||||
|
| `brotli` | https://github.com/google/brotli |
|
||||||
|
| `gzip` | https://www.gnu.org/software/gzip |
|
||||||
|
| `lz4` | https://github.com/lz4/lz4 |
|
||||||
|
| `zlib` | https://www.zlib.net |
|
||||||
|
]=]
|
||||||
export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
|
export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@interface HashAlgorithm
|
||||||
|
|
||||||
|
A hash algorithm supported by the Serde library.
|
||||||
|
|
||||||
|
Currently supported algorithms:
|
||||||
|
|
||||||
|
| Name | Learn More |
|
||||||
|
|:-----------|:-------------------------------------|
|
||||||
|
| `md5` | https://en.wikipedia.org/wiki/MD5 |
|
||||||
|
| `sha1` | https://en.wikipedia.org/wiki/SHA-1 |
|
||||||
|
| `sha224` | https://en.wikipedia.org/wiki/SHA-2 |
|
||||||
|
| `sha256` | https://en.wikipedia.org/wiki/SHA-2 |
|
||||||
|
| `sha384` | https://en.wikipedia.org/wiki/SHA-2 |
|
||||||
|
| `sha512` | https://en.wikipedia.org/wiki/SHA-2 |
|
||||||
|
| `sha3-224` | https://en.wikipedia.org/wiki/SHA-3 |
|
||||||
|
| `sha3-256` | https://en.wikipedia.org/wiki/SHA-3 |
|
||||||
|
| `sha3-384` | https://en.wikipedia.org/wiki/SHA-3 |
|
||||||
|
| `sha3-512` | https://en.wikipedia.org/wiki/SHA-3 |
|
||||||
|
| `blake3` | https://en.wikipedia.org/wiki/BLAKE3 |
|
||||||
|
]=]
|
||||||
export type HashAlgorithm =
|
export type HashAlgorithm =
|
||||||
"md5"
|
"md5"
|
||||||
| "sha1"
|
| "sha1"
|
||||||
|
@ -48,13 +99,7 @@ local serde = {}
|
||||||
|
|
||||||
Encodes the given value using the given format.
|
Encodes the given value using the given format.
|
||||||
|
|
||||||
Currently supported formats:
|
See [`EncodeDecodeFormat`] for a list of supported formats.
|
||||||
|
|
||||||
| Name | Learn More |
|
|
||||||
|:-------|:---------------------|
|
|
||||||
| `json` | https://www.json.org |
|
|
||||||
| `yaml` | https://yaml.org |
|
|
||||||
| `toml` | https://toml.io |
|
|
||||||
|
|
||||||
@param format The format to use
|
@param format The format to use
|
||||||
@param value The value to encode
|
@param value The value to encode
|
||||||
|
@ -71,13 +116,7 @@ end
|
||||||
|
|
||||||
Decodes the given string using the given format into a lua value.
|
Decodes the given string using the given format into a lua value.
|
||||||
|
|
||||||
Currently supported formats:
|
See [`EncodeDecodeFormat`] for a list of supported formats.
|
||||||
|
|
||||||
| Name | Learn More |
|
|
||||||
|:-------|:---------------------|
|
|
||||||
| `json` | https://www.json.org |
|
|
||||||
| `yaml` | https://yaml.org |
|
|
||||||
| `toml` | https://toml.io |
|
|
||||||
|
|
||||||
@param format The format to use
|
@param format The format to use
|
||||||
@param encoded The string to decode
|
@param encoded The string to decode
|
||||||
|
@ -93,14 +132,7 @@ end
|
||||||
|
|
||||||
Compresses the given string using the given format.
|
Compresses the given string using the given format.
|
||||||
|
|
||||||
Currently supported formats:
|
See [`CompressDecompressFormat`] for a list of supported formats.
|
||||||
|
|
||||||
| Name | Learn More |
|
|
||||||
|:---------|:----------------------------------|
|
|
||||||
| `brotli` | https://github.com/google/brotli |
|
|
||||||
| `gzip` | https://www.gnu.org/software/gzip |
|
|
||||||
| `lz4` | https://github.com/lz4/lz4 |
|
|
||||||
| `zlib` | https://www.zlib.net |
|
|
||||||
|
|
||||||
@param format The format to use
|
@param format The format to use
|
||||||
@param s The string to compress
|
@param s The string to compress
|
||||||
|
@ -116,14 +148,7 @@ end
|
||||||
|
|
||||||
Decompresses the given string using the given format.
|
Decompresses the given string using the given format.
|
||||||
|
|
||||||
Currently supported formats:
|
See [`CompressDecompressFormat`] for a list of supported formats.
|
||||||
|
|
||||||
| Name | Learn More |
|
|
||||||
|:---------|:----------------------------------|
|
|
||||||
| `brotli` | https://github.com/google/brotli |
|
|
||||||
| `gzip` | https://www.gnu.org/software/gzip |
|
|
||||||
| `lz4` | https://github.com/lz4/lz4 |
|
|
||||||
| `zlib` | https://www.zlib.net |
|
|
||||||
|
|
||||||
@param format The format to use
|
@param format The format to use
|
||||||
@param s The string to decompress
|
@param s The string to decompress
|
||||||
|
@ -133,10 +158,36 @@ function serde.decompress(format: CompressDecompressFormat, s: buffer | string):
|
||||||
return nil :: any
|
return nil :: any
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
|
Hashes the given message using the given algorithm
|
||||||
|
and returns the hash as a hex string.
|
||||||
|
|
||||||
|
See [`HashAlgorithm`] for a list of supported algorithms.
|
||||||
|
|
||||||
|
@param algorithm The algorithm to use
|
||||||
|
@param message The message to hash
|
||||||
|
@return The hash as a hex string
|
||||||
|
]=]
|
||||||
function serde.hash(algorithm: HashAlgorithm, message: string | buffer): string
|
function serde.hash(algorithm: HashAlgorithm, message: string | buffer): string
|
||||||
return nil :: any
|
return nil :: any
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Serde
|
||||||
|
@tag must_use
|
||||||
|
|
||||||
|
Hashes the given message using HMAC with the given secret
|
||||||
|
and algorithm, returning the hash as a base64 string.
|
||||||
|
|
||||||
|
See [`HashAlgorithm`] for a list of supported algorithms.
|
||||||
|
|
||||||
|
@param algorithm The algorithm to use
|
||||||
|
@param message The message to hash
|
||||||
|
@return The hash as a base64 string
|
||||||
|
]=]
|
||||||
function serde.hmac(
|
function serde.hmac(
|
||||||
algorithm: HashAlgorithm,
|
algorithm: HashAlgorithm,
|
||||||
message: string | buffer,
|
message: string | buffer,
|
||||||
|
|
Loading…
Reference in a new issue