card model: save uuid as u32
This commit is contained in:
+10
-8
@@ -225,7 +225,7 @@ pub struct Sprite {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Card {
|
pub struct Card {
|
||||||
pub uuid: String,
|
pub uuid: u32,
|
||||||
pub event: Events,
|
pub event: Events,
|
||||||
pub cardtype: CardType,
|
pub cardtype: CardType,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -241,14 +241,16 @@ pub struct Card {
|
|||||||
impl<'a> TryFrom<RawCard> for Card {
|
impl<'a> TryFrom<RawCard> for Card {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
|
|
||||||
fn try_from(payload: RawCard) -> Result<Self, Self::Error> {
|
fn try_from(raw_card: RawCard) -> Result<Self, Self::Error> {
|
||||||
let uuid: String = "empty for now".into(); //str::from_utf8(payload.card_uuid).unwrap().into();
|
let uuid: u32 = (u16::from_ne_bytes(raw_card.event_encoding) as u32) << 16
|
||||||
let event = decode_known_event(&payload.event_encoding);
|
| (u16::from_ne_bytes(raw_card.card_uuid) as u32);
|
||||||
let cardtype = CardType::from(payload.card_type);
|
|
||||||
let (name, trait1, trait2, trait3) = decode_packed_card_text(&payload.packed_card_text);
|
let event = decode_known_event(&raw_card.event_encoding);
|
||||||
let secret = decode_secret(&payload.secret);
|
let cardtype = CardType::from(raw_card.card_type);
|
||||||
|
let (name, trait1, trait2, trait3) = decode_packed_card_text(&raw_card.packed_card_text);
|
||||||
|
let secret = decode_secret(&raw_card.secret);
|
||||||
let sprite = Sprite {
|
let sprite = Sprite {
|
||||||
data: payload.sprite.to_vec(),
|
data: raw_card.sprite.to_vec(),
|
||||||
};
|
};
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
uuid,
|
uuid,
|
||||||
|
|||||||
Reference in New Issue
Block a user