wrapped-decimal 0.1.2

POD-safe 16-byte wrapper for rust_decimal::Decimal.
Documentation

wrapped-decimal

A fixed-size wrapper around rust_decimal::Decimal for stable byte-layout use cases.

What it provides

  • WrappedDecimal([u8; 16]) with #[repr(C)]
  • POD-safe representation for account/state layouts
  • From<Decimal> and From<WrappedDecimal> conversions
  • Optional Anchor derives via feature flags

Install

cargo add wrapped-decimal

Features

  • anchor: enable Anchor serialization/IDL traits

Example

use rust_decimal::Decimal;
use wrapped_decimal::WrappedDecimal;

let d = Decimal::new(12345, 2); // 123.45
let wrapped = WrappedDecimal::from(d);
let back = Decimal::from(wrapped);
assert_eq!(back, d);