Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 816 Bytes

File metadata and controls

36 lines (24 loc) · 816 Bytes

sqlx-msgpack

A small helper for storing serde types as MessagePack blobs with sqlx.

What it does

sqlx-msgpack provides a wrapper type:

  • SqlxMsgPack<T>

It maps T to SQL binary columns (Vec<u8> at the SQLx layer), encoding/decoding with rmp-serde.

Usage

Derive Serialize + Deserialize for your payload type, then wrap it in SqlxMsgPack<T>.

use serde::{Deserialize, Serialize};
use sqlx_msgpack::SqlxMsgPack;

#[derive(Debug, Clone, Serialize, Deserialize)]
struct Preferences {
    theme: String,
    notifications: bool,
}

#[derive(sqlx::FromRow)]
struct UserRow {
    id: i64,
    prefs: SqlxMsgPack<Preferences>,
}

License

This project is distributed under the MIT software license. See LICENSE.