Trait votable::TableDataContent
source · pub trait TableDataContent: Default + PartialEq + Serialize {
// Required methods
fn ensures_consistency(
&mut self,
context: &[TableElem]
) -> Result<(), String>;
fn read_datatable_content<R: BufRead>(
&mut self,
reader: &mut Reader<R>,
reader_buff: &mut Vec<u8>,
context: &[TableElem]
) -> Result<(), VOTableError>;
fn read_binary_content<R: BufRead>(
&mut self,
reader: &mut Reader<R>,
reader_buff: &mut Vec<u8>,
context: &[TableElem]
) -> Result<(), VOTableError>;
fn read_binary2_content<R: BufRead>(
&mut self,
reader: &mut Reader<R>,
reader_buff: &mut Vec<u8>,
context: &[TableElem]
) -> Result<(), VOTableError>;
fn write_in_datatable<W: Write>(
&mut self,
writer: &mut Writer<W>,
context: &[TableElem]
) -> Result<(), VOTableError>;
fn write_in_binary<W: Write>(
&mut self,
writer: &mut Writer<W>,
context: &[TableElem]
) -> Result<(), VOTableError>;
fn write_in_binary2<W: Write>(
&mut self,
writer: &mut Writer<W>,
context: &[TableElem]
) -> Result<(), VOTableError>;
// Provided method
fn new() -> Self { ... }
}Required Methods§
sourcefn ensures_consistency(&mut self, context: &[TableElem]) -> Result<(), String>
fn ensures_consistency(&mut self, context: &[TableElem]) -> Result<(), String>
When deserializing from JSON, TOML or YAML, we should implement a ‘DeserializeSeed’ based on the table Schema. But:
- we have to implement
Deserializeby hand onTable,Data,DataElem,TableData,Binary,Binary2andStream, which is daunting task, even usingcargo expand… - even so, the metadata may be parsed after the data (e.g. in JSON the key order is not guaranteed to be preserved)
So, the result of the deserialization without knowing the table schema may result in
no-homogeneous datatype in a same column.
E.g short and int, or char and string may be mixed.
So, we use this method to replace incorrect types by the porper ones as a post-parsing process. This is not ideal on a performance point-of-view, but Serde usage to convert from JSON, TOML and YAML should be limited to small tables (less than a few hundreds of megabytes).
sourcefn read_datatable_content<R: BufRead>(
&mut self,
reader: &mut Reader<R>,
reader_buff: &mut Vec<u8>,
context: &[TableElem]
) -> Result<(), VOTableError>
fn read_datatable_content<R: BufRead>( &mut self, reader: &mut Reader<R>, reader_buff: &mut Vec<u8>, context: &[TableElem] ) -> Result<(), VOTableError>
Called when Event::Start(“DATATABLE”) as been detected and MUST return after event Event::End(“DATATABLE”)
sourcefn read_binary_content<R: BufRead>(
&mut self,
reader: &mut Reader<R>,
reader_buff: &mut Vec<u8>,
context: &[TableElem]
) -> Result<(), VOTableError>
fn read_binary_content<R: BufRead>( &mut self, reader: &mut Reader<R>, reader_buff: &mut Vec<u8>, context: &[TableElem] ) -> Result<(), VOTableError>
Called when Event::Start(“STREAM”) as been detected (in BINARY) and MUST return after event Event::End(“STREAM”)
sourcefn read_binary2_content<R: BufRead>(
&mut self,
reader: &mut Reader<R>,
reader_buff: &mut Vec<u8>,
context: &[TableElem]
) -> Result<(), VOTableError>
fn read_binary2_content<R: BufRead>( &mut self, reader: &mut Reader<R>, reader_buff: &mut Vec<u8>, context: &[TableElem] ) -> Result<(), VOTableError>
Called when Event::Start(“STREAM”) as been detected (in BINARY2) and MUST return after event Event::End(“STREAM”)