Browse Source

start config maybe

master
Avril 6 months ago
parent
commit
cd1bd5f7da
Signed by: flanchan GPG Key ID: 284488987C31F630
  1. 16
      src/ext.rs
  2. 7
      src/formats.rs

16
src/ext.rs

@ -1,6 +1,9 @@
use super::*;
use std::{
io::{self, Read, Write},
any::Any,
marker::{Send, Sync},
fmt,
};
pub trait Tuple2Ext<T,U>: Sized
@ -109,3 +112,16 @@ impl<R: io::Read> IOCounterReadExt for R
}
}
/// A boxed `'static` value of anything anything that is `Send` and `Sync`.
#[repr(transparent)]
pub struct Anything(pub Box<dyn Any + Send + Sync + 'static>);
impl fmt::Debug for Anything
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
write!(f, "<opaque object>: (at: {:p}, sz: {})",
Box::as_ref(&self.0),
std::mem::size_of_val(Box::as_ref(&self.0)))
}
}

7
src/formats.rs

@ -11,7 +11,12 @@ use object::Object;
mod json;
/// Config for the encode/decode
pub struct Config; //TODO: What goes here?
#[derive(Debug)]
pub struct Config{
//TODO: What goes here?
/// Any arbitrary data.
pub user: Option<Anything>,
}
/// A directive for a format on how to encode and decode objects.
#[derive(Clone, Copy)]

Loading…
Cancel
Save