pub struct TransferToken {
pub token_id: Uuid,
pub player_id: PlayerId,
pub source_server: ServerId,
pub target_server: ServerId,
pub created_at: DateTime<Utc>,
pub expires_at: DateTime<Utc>,
pub signature: String,
pub player_state: String,
}Expand description
Transfer token that authorizes a player to connect to a new server.
This token is generated by Atlas and must be presented by the player when connecting to the target server to prove they are authorized.
Fields§
§token_id: UuidUnique token identifier
player_id: PlayerIdPlayer being transferred
source_server: ServerIdSource server
target_server: ServerIdTarget server
created_at: DateTime<Utc>When this token was created
expires_at: DateTime<Utc>When this token expires
signature: StringCryptographic signature (HMAC or similar)
player_state: StringSerialized player state
Implementations§
Source§impl TransferToken
impl TransferToken
Sourcepub fn new(
player_id: PlayerId,
source_server: ServerId,
target_server: ServerId,
player_state: PlayerState,
valid_duration_secs: i64,
secret_key: &[u8],
) -> Result<Self, TransferError>
pub fn new( player_id: PlayerId, source_server: ServerId, target_server: ServerId, player_state: PlayerState, valid_duration_secs: i64, secret_key: &[u8], ) -> Result<Self, TransferError>
Creates a new transfer token.
The token is valid for the specified duration.
Sourcepub fn verify(&self, secret_key: &[u8]) -> Result<(), TransferError>
pub fn verify(&self, secret_key: &[u8]) -> Result<(), TransferError>
Verifies the token signature and expiration.
Sourcepub fn extract_player_state(&self) -> Result<PlayerState, TransferError>
pub fn extract_player_state(&self) -> Result<PlayerState, TransferError>
Extracts the player state from the token.
Trait Implementations§
Source§impl Clone for TransferToken
impl Clone for TransferToken
Source§fn clone(&self) -> TransferToken
fn clone(&self) -> TransferToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TransferToken
impl Debug for TransferToken
Source§impl<'de> Deserialize<'de> for TransferToken
impl<'de> Deserialize<'de> for TransferToken
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TransferToken
impl RefUnwindSafe for TransferToken
impl Send for TransferToken
impl Sync for TransferToken
impl Unpin for TransferToken
impl UnwindSafe for TransferToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more