pub struct NdefRecord {
pub record_type: String,
pub media_type: Option<String>,
pub id: Option<String>,
pub encoding: Option<String>,
pub lang: Option<String>,
pub data: Option<String>,
pub data_base64: Option<Bytes>,
}Expand description
One NDEF record, as Web NFC’s NDEFRecordInit.
use hardless_core::NdefRecord;
let text: NdefRecord =
serde_json::from_str(r#"{ "recordType": "text", "data": "Hello", "lang": "en" }"#).unwrap();
assert_eq!(text.payload(), b"Hello");
let png: NdefRecord = serde_json::from_str(
r#"{ "recordType": "mime", "mediaType": "image/png", "dataBase64": "iVBORw==" }"#,
).unwrap();
assert_eq!(png.payload(), b"\x89PNG");
assert!(text.validate().is_ok() && png.validate().is_ok());Fields§
§record_type: Stringempty, text, url, absolute-url, mime, unknown, or an external type such as
example.com:loyalty.
media_type: Option<String>The MIME type of a mime record, e.g. application/json.
id: Option<String>The record identifier.
encoding: Option<String>The text encoding of a text record: utf-8 (default), utf-16, utf-16be or
utf-16le.
lang: Option<String>The language of a text record, e.g. en.
data: Option<String>A text payload: the text of a text record, the URL of a url record, or any payload
that is UTF-8 text.
data_base64: Option<Bytes>A binary payload, base64. At most one of data and dataBase64 is set.
Implementations§
Trait Implementations§
Source§impl Clone for NdefRecord
impl Clone for NdefRecord
Source§impl Debug for NdefRecord
impl Debug for NdefRecord
Source§impl Default for NdefRecord
impl Default for NdefRecord
Source§impl<'de> Deserialize<'de> for NdefRecord
impl<'de> Deserialize<'de> for NdefRecord
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
impl Eq for NdefRecord
Source§impl JsonSchema for NdefRecord
impl JsonSchema for NdefRecord
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for NdefRecord
impl PartialEq for NdefRecord
Source§impl Serialize for NdefRecord
impl Serialize for NdefRecord
impl StructuralPartialEq for NdefRecord
Auto Trait Implementations§
impl !Freeze for NdefRecord
impl RefUnwindSafe for NdefRecord
impl Send for NdefRecord
impl Sync for NdefRecord
impl Unpin for NdefRecord
impl UnsafeUnpin for NdefRecord
impl UnwindSafe for NdefRecord
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