pub struct Record { /* private fields */ }Expand description
A single contact record, composed of multiple data fields
Implementations§
Source§impl Record
impl Record
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new record.
use difa::Record;
let mut record = Record::new();
record.insert("call", "W1AW").unwrap();
record.insert("freq", "14.074").unwrap();
assert_eq!(record.get("call").unwrap().as_str(), "W1AW");Sourcepub fn new_header() -> Self
pub fn new_header() -> Self
Create a new header record.
use difa::Record;
let mut header = Record::new_header();
header.insert("adifver", "3.1.4").unwrap();
assert!(header.is_header());
assert_eq!(header.get("adifver").unwrap().as_str(), "3.1.4");Sourcepub fn is_header(&self) -> bool
pub fn is_header(&self) -> bool
True if this record represents an ADIF header.
use difa::RecordStream;
use futures::StreamExt;
let mut s = RecordStream::new(
"<adifver:5>3.1.4<eoh><call:4>W1AW<eor>".as_bytes(),
true,
);
let header = s.next().await.unwrap().unwrap();
assert!(header.is_header());
let record = s.next().await.unwrap().unwrap();
assert!(!record.is_header());Sourcepub fn get(&self, name: &str) -> Option<&Datum>
pub fn get(&self, name: &str) -> Option<&Datum>
Return the value of the requested field.
use difa::RecordStream;
use futures::StreamExt;
let mut s = RecordStream::new(
"<call:4>W1AW<freq:6>14.074<eor>".as_bytes(),
true,
);
let record = s.next().await.unwrap().unwrap();
assert_eq!(record.get("call").unwrap().as_str(), "W1AW");
assert_eq!(record.get("freq").unwrap().as_str(), "14.074");
assert!(record.get("missing").is_none());Sourcepub fn insert<N, V>(&mut self, name: N, value: V) -> Result<(), Error>
pub fn insert<N, V>(&mut self, name: N, value: V) -> Result<(), Error>
Add a field to the record.
Overwriting a previous value is not permitted and will return an error. Transformations can only add new keys, not delete or replace them.
Since colons cannot occur in tag names, a custom transformation may wish to convert tag “xxx” to “myapp:xxx”.
use difa::{Datum, RecordStream};
use futures::StreamExt;
let mut s = RecordStream::new("<call:4>W1AW<eor>".as_bytes(), true);
let mut record = s.next().await.unwrap().unwrap();
record
.insert("band".to_string(), Datum::String("20M".to_string()))
.unwrap();
assert_eq!(record.get("band").unwrap().as_str(), "20M");
let err = record
.insert("call".to_string(), Datum::String("AB9BH".to_string()));
assert!(err.is_err());Sourcepub fn into_fields(self) -> impl Iterator<Item = (String, Datum)>
pub fn into_fields(self) -> impl Iterator<Item = (String, Datum)>
Consume the record and return an iterator over owned fields.
Trait Implementations§
Source§impl<W> Sink<Record> for CabrilloSink<W>where
W: AsyncWrite + Unpin,
impl<W> Sink<Record> for CabrilloSink<W>where
W: AsyncWrite + Unpin,
Source§fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Attempts to prepare the
Sink to receive a value. Read moreSource§fn start_send(self: Pin<&mut Self>, r: Record) -> Result<(), Error>
fn start_send(self: Pin<&mut Self>, r: Record) -> Result<(), Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreSource§impl<W> Sink<Record> for RecordSink<W>where
W: AsyncWrite + Unpin,
impl<W> Sink<Record> for RecordSink<W>where
W: AsyncWrite + Unpin,
Source§fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSource§fn start_send(self: Pin<&mut Self>, item: Record) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: Record) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreimpl Eq for Record
impl StructuralPartialEq for 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 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.