From 033d70589f98a016c659574f58647bd40e7b12b2 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 27 Nov 2020 17:47:12 +0000 Subject: [PATCH] newtype for outsourced file ids --- src/server/data.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/data.rs b/src/server/data.rs index a79f180..bc8256f 100644 --- a/src/server/data.rs +++ b/src/server/data.rs @@ -29,6 +29,8 @@ use tokio::io::{ #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct AbsoluteIndex(Vec); +id_type!(pub CachedFileId: "The file path is this ID inside the data dir. It may be subject to caching"); + /// Possible value types of the data map #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum Data @@ -53,12 +55,12 @@ pub enum Data /// /// The file path is this ID inside the data dir. It may be subject to caching later down the line, and will require deleting when an Atom of this type is removed. /// The files corresponding to these entries should be lazy-loaded (as open `tokio::fs::File`s) into a `DelayQueue` for caching. - TextFile(uuid::Uuid), + TextFile(CachedFileId), /// A binary blob outsourced to a file. /// /// The file path is this ID inside the data dir. It may be subject to caching later down the line, and will require deleting when an Atom of this type is removed. /// The files corresponding to these entries should be lazy-loaded (as open `tokio::fs::File`s) into a `DelayQueue` for caching. - BinaryFile(uuid::Uuid), + BinaryFile(CachedFileId), /// A reference index to an item within the same `Datamap` as this one. RelativeRef(Index),