Expand description
§GXT (Game Exchange Token)
Minimal, encrypted, signed and copy-pasteable tokens for manual data exchange between games.
For details check out spec.md.
Note: This is intended to be used as a base for mods to exchange data in a secure way. The protocol only handles the data exchange part. It is on the integrator to ensure that the the correct actions take place inside the game. For trades, it is recommended to remove the offered items from the inventory of the player when the trade is created in order to avoid people offering items and then giving them away before the trade is completed.
Its also recommended to save the game state after a trade is created in order to avoid save scumming. You should also store the ID of a trade so that it can be verified that a message was in response to that ID. When responding to a message, make sure you set the parent field to the ID of the message you’re responding to. Otherwise there is no way to verify the message chain.
You might also want to store some lightweight meta data for the trade request. For instance the identifiers of the items that were taken away. This way they can be given back when the other player cancels a trade. The trade result defined in the advisory module contains data from the original request that can be used to give items back or to award the items from the fulfillment.
Modules§
- advisory
- The advisory module contains simple structures that can be used as a base for implementing trades.
Macros§
- json
- Construct a
serde_json::Valuefrom a JSON literal.
Structs§
- Envelope
- Parsed, verified GXT record.
Enums§
- GxtError
- Errors that can occur while encoding, decoding, compressing, or verifying GXT tokens.
- Json
Value - Represents any valid JSON value.
- KeyKind
- The kind of key
- Payload
Kind - What kind of payload was sent
Functions§
- decrypt_
message - Verify the signature of a message, decrypt its payload and return a parsed
Envelope. - encrypt_
message - Create an encrypted message for the owner of the ID card that was passed in.
- from_
json - Helper function to deserialize a string into an arbitrary value, that implement the
Serializetrait - from_
value - Interpret a
serde_json::Valueas an instance of typeT. - make_
id_ card - Creates an ID card containing the necessary data for the encrypted communication and some opaque meta data.
- make_
key - Creates a private key for a peer.
- to_json
- Helper function to serialize arbitrary values, that implement the
Serializetrait, into strings - to_
json_ pretty - Helper function to serialize arbitrary values, that implement the
Serializetrait, into strings and format it nicely - to_
value - Convert a
Tintoserde_json::Valuewhich is an enum that can represent any valid JSON data. - value_
from_ str - Helper function to deserialize strings into json values
- value_
to_ string - Helper function to serialize json values into strings
- verify_
message - Verify the signature of a message and return a parsed
Envelope.