generate_qr_data

Function generate_qr_data 

Source
pub fn generate_qr_data<T: Serialize>(data: &T) -> QrResult<Vec<u8>>
Expand description

Generate binary data from any postcard-serializable data for QR code encoding

This function serializes the data using postcard and returns the binary data directly for QR code generation.

§Arguments

  • data - The data to encode (must implement Serialize)

§Returns

  • QrResult<Vec<u8>> - The binary data that can be used to generate the QR code

§Examples

use zoe_app_primitives::qr::generate_qr_data;
use serde::Serialize;

#[derive(Serialize)]
struct MyData {
    message: String,
}

let data = MyData { message: "Hello, World!".to_string() };
let qr_data = generate_qr_data(&data).unwrap();