Moved Record into document module.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
@@ -1,8 +1,39 @@
|
||||
use crate::{
|
||||
message::wrapper::{InternalRecord, InternalRecords, Oid, Record},
|
||||
name::{Name, Names},
|
||||
action::Field,
|
||||
message::wrapper::{InternalRecord, InternalRecords, Oid},
|
||||
mtterror::{ErrorID, MTTError},
|
||||
name::{Name, NameType, Names},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Record {
|
||||
names: Names,
|
||||
data: InternalRecord,
|
||||
}
|
||||
|
||||
impl Record {
|
||||
pub fn with_data(names: Names, rec: InternalRecord) -> Self {
|
||||
Self {
|
||||
names: names,
|
||||
data: rec,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get<NT>(&self, field_id: NT) -> Result<Field, MTTError>
|
||||
where
|
||||
NT: Into<NameType>,
|
||||
{
|
||||
let id = match self.names.get_id(field_id) {
|
||||
Ok(data) => data,
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
match self.data.get(&id) {
|
||||
Some(data) => Ok(data.clone()),
|
||||
None => Err(MTTError::new(NameType::None, ErrorID::FieldMissingData)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Records {
|
||||
names: Names,
|
||||
|
||||
Reference in New Issue
Block a user