Binary and Text file Data types

master
Avril 4 years ago
parent 4daeea0b4e
commit 531d6557c4
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -5,6 +5,9 @@ use std::{
borrow::Cow, borrow::Cow,
error, error,
fmt, fmt,
path::PathBuf,
fs,
num::NonZeroI32,
}; };
use generational_arena::{ use generational_arena::{
Arena, Index, Arena, Index,
@ -46,6 +49,17 @@ pub enum Data
/// A binary blob /// A binary blob
Binary(Vec<u8>), Binary(Vec<u8>),
/// A UTF-8 text string 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.
TextFile(uuid::Uuid),
/// 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),
/// A reference index to an item within the same `Datamap` as this one. /// A reference index to an item within the same `Datamap` as this one.
RelativeRef(Index), RelativeRef(Index),
/// A reference to an item N deep within nested `Map` elements. /// A reference to an item N deep within nested `Map` elements.

@ -74,13 +74,14 @@ impl<'u> iter::DoubleEndedIterator for Groups<'u>
{ {
fn next_back(&mut self) -> Option<Self::Item> fn next_back(&mut self) -> Option<Self::Item>
{ {
if self.0 == 0 { if self.0 == 0 || self.0 >= self.1.len() {
None self.0 = self.1.len()-1;
} else { } else {
self.0-=1; self.0-=1;
debug_assert!(self.0<self.1.len(), "bad DEI impl");
Some(self.2.groups.get(&self.1[self.0]).expect("Groups contained invalid group ID for its userspace"))
} }
debug_assert!(self.0<self.1.len(), "bad DEI impl");
Some(self.2.groups.get(&self.1[self.0]).expect("Groups contained invalid group ID for its userspace"))
} }
} }
impl<'u> iter::ExactSizeIterator for Groups<'u>{} impl<'u> iter::ExactSizeIterator for Groups<'u>{}

Loading…
Cancel
Save