Crate gxt

Crate gxt 

Source
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::Value from a JSON literal.

Structs§

Envelope
Parsed, verified GXT record.

Enums§

GxtError
Errors that can occur while encoding, decoding, compressing, or verifying GXT tokens.
JsonValue
Represents any valid JSON value.
KeyKind
The kind of key
PayloadKind
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 Serialize trait
from_value
Interpret a serde_json::Value as an instance of type T.
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 Serialize trait, into strings
to_json_pretty
Helper function to serialize arbitrary values, that implement the Serialize trait, into strings and format it nicely
to_value
Convert a T into serde_json::Value which 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.