chiark / gitweb /
AssetUrlKey: save and restore
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 4 May 2021 01:31:16 +0000 (02:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 4 May 2021 11:27:30 +0000 (12:27 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bundles.rs
src/global.rs

index 8a9c7eebf7560875628706ae6a33624719dc5888..793b5ec8e0f2a12ae9c5da43778c65bcfda7df40 100644 (file)
@@ -47,7 +47,7 @@ hformat_as_display!{Id}
 
 const BUNDLES_MAX: Index = Index(64);
 
-#[derive(Clone)]
+#[derive(Clone,Serialize,Deserialize)]
 pub enum AssetUrlKey {
   Dummy,
   Y(AssetUrlKeyRaw),
@@ -63,6 +63,7 @@ impl Debug for AssetUrlKey {
     }
   }
 }
+impl Default for AssetUrlKey { fn default() -> Self { Self::Dummy } }
 impl AssetUrlKey {
   #[throws(IE)]
   pub fn new_random() -> AssetUrlKey {
index 22c02f30e6461885f82da2c92696839354b87e1a..952cee4b462edc38614ecda6d5c585387d6eef31 100644 (file)
@@ -242,6 +242,7 @@ struct InstanceSaveAuxiliary<RawTokenStr, PiecesLoadedRef, OccultIlksRef,
   aplayers: SecondarySlotMap<PlayerId, IPlayer>,
   acl: Acl<TablePermission>,
   pub links: Arc<LinksTable>,
+  asset_url_key: AssetUrlKey,
 }
 
 pub struct PrivateCaller(());
@@ -1062,9 +1063,10 @@ impl InstanceGuard<'_> {
       ).collect();
       let acl = s.c.g.acl.clone().into();
       let links = s.c.g.links.clone();
+      let asset_url_key = s.c.g.asset_url_key.clone();
       let isa = InstanceSaveAuxiliary {
         ipieces, ioccults, tokens_players, aplayers, acl, links,
-        pcaliases,
+        pcaliases, asset_url_key,
       };
       rmp_serde::encode::write_named(w, &isa)
     })?;
@@ -1089,7 +1091,7 @@ impl InstanceGuard<'_> {
                name: InstanceName) -> Option<InstanceRef> {
     let InstanceSaveAuxiliary::<String,ActualIPieces,IOccults,PieceAliases> {
       tokens_players, mut ipieces, ioccults, mut aplayers, acl, links,
-      pcaliases,
+      pcaliases, asset_url_key,
     } = match Self::load_something(&name, "a-") {
       Ok(data) => data,
       Err(e) => if (||{
@@ -1160,7 +1162,7 @@ impl InstanceGuard<'_> {
       tokens_clients: default(),
       tokens_players: default(),
       bundle_list: default(), // set by load_game_bundles
-      asset_url_key: AssetUrlKey::Dummy,
+      asset_url_key,
     };
 
     let b = InstanceBundles::load_game_bundles(&mut g)?;