pub struct Record {
pub id: u64,
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.
Fields§
§id: u64§fields: AHashMap<String, FieldValue>§source: Option<String>Implementations§
Source§impl Record
impl Record
pub fn new(id: u64) -> Record
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.37));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>,
Deserialize this value from the given Serde deserializer. Read more
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,
Serialize this value into the given Serde serializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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