pub struct Record {
pub id: u64,
pub key: String,
pub fields: AHashMap<String, FieldValue>,
pub source: Option<String>,
}Expand description
A single data record with a unique ID and a map of field values.
id is an internal u64 used for fast indexing and joins. treat it as
opaque. key is the user-visible natural key: the value of whichever
column was nominated as the identity column when loading the dataset (e.g.
BSN, UUID, or primary-key value). The .zes output references records by
(source, key), not by id.
§Construction
Record::from_key. preferred when loading real data via azer_adapters::DatasetConfig. Derivesidfromhash(source:key).Record::new. for synthetic/test records; setskey = id.to_string().
Fields§
§id: u64§key: String§fields: AHashMap<String, FieldValue>§source: Option<String>Implementations§
Source§impl Record
impl Record
Sourcepub fn new(id: u64) -> Record
pub fn new(id: u64) -> Record
Create a record with an explicit numeric ID.
key is set to id.to_string(). Use this only for synthetic or test
records. For real data use Record::from_key so that the natural
key is preserved in the .zes output.
Sourcepub fn from_key(source: impl Into<String>, key: impl Into<String>) -> Record
pub fn from_key(source: impl Into<String>, key: impl Into<String>) -> Record
Create a record whose identity comes from a natural key column.
id is derived deterministically via FNV-1a(source:key) so that the
same (source, key) pair always produces the same internal ID. The
source label is stored on the record, so calling Record::with_source
afterwards is not required (but is a no-op).
pub fn with_source(self, source: impl Into<String>) -> Record
pub fn insert( self, name: impl Into<String>, value: impl Into<FieldValue>, ) -> Record
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>(&self, name: &str) -> Option<T>where
T: FromFieldValue,
pub fn field_as<T>(&self, name: &str) -> Option<T>where
T: FromFieldValue,
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.37f64));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Record, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Record, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl IntoRecord for Record
impl IntoRecord for Record
fn into_record(self, _id: u64) -> Record
Source§impl Serialize for Record
impl Serialize for Record
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more