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,
error,
fmt,
path::PathBuf,
fs,
num::NonZeroI32,
};
use generational_arena::{
Arena, Index,
@ -46,6 +49,17 @@ pub enum Data
/// A binary blob
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.
RelativeRef(Index),
/// 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>
{
if self.0 == 0 {
None
if self.0 == 0 || self.0 >= self.1.len() {
self.0 = self.1.len()-1;
} else {
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"))
}
}
}
impl<'u> iter::ExactSizeIterator for Groups<'u>{}

Loading…
Cancel
Save