serializeToToml

fun <T : Any> serializeToToml(config: T, errorHeader: String = "", flags: Byte = 1): ValidationResult<TomlElement>

Serialize a config class to a TomlElement

Custom serializer, powered by TomlKt. Serialization occurs in two ways

  1. EntrySerializer elements are serialized with their custom serializeEntry method

  2. "Raw" properties and fields are serialized with the TomlKt by-class-type serialization.

Will serialize the available TomlAnnotations, for use in proper formatting, comment generation, etc. Note that if you register the config on the client side, TOML formatting may not be critical, as the user will generally edit the config in-game.

  • TomlHeaderComment and Version: Will add top-of-file comments above the

  • TomlComment: Adds a comment to the Toml file output. Accepts single line ("..") or multi-line ("""..""") comments

  • TomlBlockArray: marks a list or other array object as a Block Array (Multi-line list). Default items per line is 1

  • TomlInline: Marks that the annotated table or array element should be serialized as one line. Overrides TomlBlockArray

  • TomlMultilineString: Marked string parses to file as a multi line string

Should be called as a matched pair to deserializeFromToml. Ex: if ignoreNonSync is false on one end, it needs to be false on the other.

Return

Returns a ValidationResult wrapping a TomlElement of the serialized config as well as any error context

Author

fzzyhmstrs

Since

0.2.0, deprecated 0.7.0 and scheduled for removal 0.8.0

Parameters

T

Type of the config to serialize. Can be any Non-Null type.

config

the config instance to serialize from

errorHeader

String header message that the deserializer will use when building it's ValidationResult.

flags

default IGNORE_NON_SYNC. With the default, elements with the NonSync annotation will be skipped. See the flag options below to serialize the entire config (ex: saving to file), fully syncing (ex: initial sync server -> client), etc.

  • CHECK_NON_SYNC: Byte = 0

  • IGNORE_NON_SYNC: Byte = 1

  • CHECK_RESTART: Byte = 2

  • IGNORE_NON_SYNC_AND_CHECK_RESTART: Byte = 3

  • IGNORE_VISIBILITY: Byte = 4


fun <T : Any> serializeToToml(config: T, errorBuilder: MutableList<String>, flags: Byte = 1): TomlElement

Deprecated

Use overload that takes a ValidationResult.ErrorEntry.Mutable. Scheduled for removal 0.8.0

Serialize a config class to a TomlElement

Custom serializer, powered by TomlKt. Serialization occurs in two ways

  1. EntrySerializer elements are serialized with their custom serializeEntry method

  2. "Raw" properties and fields are serialized with the TomlKt by-class-type serialization.

Will serialize the available TomlAnnotations, for use in proper formatting, comment generation, etc. Note that if you register the config on the client side, TOML formatting may not be critical, as the user will generally edit the config in-game.

  • TomlHeaderComment and Version: Will add top-of-file comments above the

  • TomlComment: Adds a comment to the Toml file output. Accepts single line ("..") or multi-line ("""..""") comments

  • TomlBlockArray: marks a list or other array object as a Block Array (Multi-line list). Default items per line is 1

  • TomlInline: Marks that the annotated table or array element should be serialized as one line. Overrides TomlBlockArray

  • TomlMultilineString: Marked string parses to file as a multi line string

Should be called as a matched pair to deserializeFromToml. Ex: if ignoreNonSync is false on one end, it needs to be false on the other.

Return

Returns a TomlElement of the serialized config

Author

fzzyhmstrs

Since

0.2.0, deprecated 0.7.0 and scheduled for removal 0.8.0

Parameters

T

Type of the config to serialize. Can be any Non-Null type.

config

the config instance to serialize from

errorBuilder

the error list. error messages are appended to this for display after the serialization call

flags

default IGNORE_NON_SYNC. With the default, elements with the NonSync annotation will be skipped. See the flag options below to serialize the entire config (ex: saving to file), fully syncing (ex: initial sync server -> client), etc.

  • CHECK_NON_SYNC: Byte = 0

  • IGNORE_NON_SYNC: Byte = 1

  • CHECK_RESTART: Byte = 2

  • IGNORE_NON_SYNC_AND_CHECK_RESTART: Byte = 3

  • IGNORE_VISIBILITY: Byte = 4


fun <T : Any> serializeToToml(config: T, errorBuilder: ValidationResult.ErrorEntry.Mutable, flags: Byte = 1): ValidationResult<TomlElement>

Deprecated

Use overload that takes a ValidationResult.ErrorEntry.Mutable. Scheduled for removal 0.8.0

Serialize a config class to a TomlElement

Custom serializer, powered by TomlKt. Serialization occurs in two ways

  1. EntrySerializer elements are serialized with their custom serializeEntry method

  2. "Raw" properties and fields are serialized with the TomlKt by-class-type serialization.

Will serialize the available TomlAnnotations, for use in proper formatting, comment generation, etc. Note that if you register the config on the client side, TOML formatting may not be critical, as the user will generally edit the config in-game.

  • TomlHeaderComment and Version: Will add top-of-file comments above the

  • TomlComment: Adds a comment to the Toml file output. Accepts single line ("..") or multi-line ("""..""") comments

  • TomlBlockArray: marks a list or other array object as a Block Array (Multi-line list). Default items per line is 1

  • TomlInline: Marks that the annotated table or array element should be serialized as one line. Overrides TomlBlockArray

  • TomlMultilineString: Marked string parses to file as a multi line string

Should be called as a matched pair to deserializeFromToml. Ex: if ignoreNonSync is false on one end, it needs to be false on the other.

Return

Returns a ValidationResult wrapping a TomlElement of the serialized config as well as any error context

Author

fzzyhmstrs

Since

0.2.0, deprecated 0.7.0 and scheduled for removal 0.8.0

Parameters

T

Type of the config to serialize. Can be any Non-Null type.

config

the config instance to serialize from

errorBuilder

ValidationResult.ErrorEntry.Mutable instance that the deserializer will apply errors to and then use when building it's ValidationResult. Using ValidationResult.createMutable() is a good way to provide a fresh empty mutable error, with an optional header error message.

flags

default IGNORE_NON_SYNC. With the default, elements with the NonSync annotation will be skipped. See the flag options below to serialize the entire config (ex: saving to file), fully syncing (ex: initial sync server -> client), etc.

  • CHECK_NON_SYNC: Byte = 0

  • IGNORE_NON_SYNC: Byte = 1

  • CHECK_RESTART: Byte = 2

  • IGNORE_NON_SYNC_AND_CHECK_RESTART: Byte = 3

  • IGNORE_VISIBILITY: Byte = 4