pub struct Record {
pub id: RecordId,
pub fields: AHashMap<FieldName, FieldValue>,
pub source: Option<String>,
}Expand description
A single data record with a unique ID and a map of field values.
Fields§
§id: RecordId§fields: AHashMap<FieldName, FieldValue>§source: Option<String>Implementations§
Source§impl Record
impl Record
pub fn new(id: RecordId) -> Self
pub fn with_source(self, source: impl Into<String>) -> Self
pub fn insert( self, name: impl Into<String>, value: impl Into<FieldValue>, ) -> Self
pub fn get(&self, name: &str) -> Option<&FieldValue>
pub fn text(&self, name: &str) -> Option<&str>
Sourcepub fn field_as_str(&self, name: &str) -> Option<Cow<'_, str>>
pub fn field_as_str(&self, name: &str) -> Option<Cow<'_, str>>
Returns the field value as a string, coercing non-text scalars to their string representation.
Sourcepub fn field_as<T: FromFieldValue>(&self, name: &str) -> Option<T>
pub fn field_as<T: FromFieldValue>(&self, name: &str) -> Option<T>
Extract a typed value from a named field using the FromFieldValue trait.
use zer_core::record::{Record, FieldValue};
let r = Record::new(1).insert("lat", 52.37f64);
let lat: Option<f64> = r.field_as::<f64>("lat");
assert_eq!(lat, Some(52.37));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl IntoRecord for Record
impl IntoRecord for Record
fn into_record(self, _id: RecordId) -> Record
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more