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