chiark / gitweb /
Document OccultOwningId serialisation and refcount rules
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 23 Apr 2022 18:09:51 +0000 (19:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 27 Apr 2022 20:49:34 +0000 (21:49 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/global.rs
src/occultilks.rs

index 2a8a2ab71cd395fa1c3fd2fcce207f7b996a67d2..487d79a72aa174d1012d2dd554b8f0d7834355e2 100644 (file)
@@ -77,6 +77,7 @@ pub struct IPlayer { // usual variable: ipl
 }
 
 #[derive(Debug,Serialize,Deserialize)]
+/// Strange ownership and serialisation rules, like `OccultIlkOwningId`
 pub struct IPiece {
   pub p: IPieceTraitObj,
   pub occilk: Option<IOccultIlk>,
index eb00577706e8eca4d90b45f914bc01d2f725e4fd..57772d8555ddfddf3838ac6ffd6936591a749fc7 100644 (file)
@@ -7,6 +7,13 @@ use crate::prelude::*;
 slotmap::new_key_type!{ pub struct OccultIlkId; }
 
 /// Does *not* `impl Drop`.  Don't just drop it.
+///
+/// Must be serialized *only* in aux (ig, Instance) *not* GameState!
+/// Otherwise refcount could be inconsistent.
+///
+/// Barring such errors, the refcount in an Instance's IOccultIlks
+/// will be the count of OccultIlkOwningIds elsewhere in the Instance,
+/// and the same will go for the saved aux file.
 #[derive(Debug,Serialize,Deserialize)]
 #[serde(transparent)]
 pub struct OccultIlkOwningId(Id);
@@ -39,7 +46,10 @@ pub enum LOccultIlk {
 }
 
 serde_with_compat!{
-  [ #[derive(Debug,Serialize,Deserialize)] ]
+  [ 
+    /// Strange ownership and serialisation rules, like `OccultIlkOwningId`
+    #[derive(Debug,Serialize,Deserialize)]
+  ]
   [ pub ][ enum ] IOccultIlk="IOccultIlk" IOccultIlk_New "IOccultIlk_Compat" [
     {
       Distinct(OccultIlkData),