A quality of life package for Anchor.

Overview

anchor-cereal

A quality of life package for Anchor made to support the Solana ecosystem. Currently, it allows you to serialize a struct containing an array of any size, while still showing up in your IDL. More features coming soon!! :)

Usage

use anchor_cereal::array::*;

...

// Define a struct to wrap your array - it must:
//   - derive Clone, AnchorSerializeArray, and AnchorDeserializeArray
//   - contain a single field named `value`, which is an array.
#[derive(Clone, AnchorSerializeArray, AnchorDeserializeArray)]
pub struct BigData {
    value: [u8; 50]
}

// You can then use your struct in accounts...
#[account]
pub struct MyAccount {
    data: BigData
}

...

// ...and instructions.
pub fn initialize(
   ctx: Context<Initialize>,
   data: BigData
) -> Result<()> {
   let my_account = &mut ctx.accounts.my_account;

   my_account.data = data;

   // BigData gets implementations for Deref and DerefMut via the deserialize
   // trait, so you don't have to reference the inner `value` in order to use
   // the array.
   let first = my_account.data[0];
   my_account.data[1] = 2;
   // Same as:
   //   let first = my_account.data.value[0];
   //   my_account.data.value[1] = 2;

   ...

   Ok(())
}
You might also like...
Print pacman package files

Paccat Print pacman package files Usage paccat [options] targets -- files a target can be specified as pkgname, repo/pkgname, url or file

Tool to build OSX package installers

📦 Pak MacOS package installer builder What does pak do? Pak builds MacOS package installers from a project file. Since apple removed PackageBuilder f

Rust crate `needleman_wunsch` of the `fasebare` package: reading FASTA sequences, Needleman-Wunsch alignment

fasebare Rust crate needleman_wunsch of the fasebare package: reading FASTA sequences, Needleman-Wunsch alignment. Synopsis The crate needleman_wunsch

Gecko's trusty package manager and command-line utility.
Gecko's trusty package manager and command-line utility.

Geckos have super-powers, ya'know? Grip is Gecko's trusty package manager and command-line utility. USAGE: grip [FLAGS] [file] [SUBCOMMAND] FLAGS

Yfin is the Official package manager for the Y-flat programming language
Yfin is the Official package manager for the Y-flat programming language

Yfin is the Official package manager for the Y-flat programming language. Yfin allows the user to install, upgrade, and uninstall packages. It also allows a user to initialize a package with the Y-flat package structure and files automatically generated. In future, Yfin will also allow users to publish packages.

A Rust CLI to provide last publish dates for packages in a package-lock.json file

NPM Package Age A Rust CLI which if you provide a npm lockfile (package-lock.json to start), it will give you a listing of all of the packages & the l

AUR external package builder

AUR Build Server Goal This project aims to provide an external package making server based on any PKGBUILD based project. Right now it pulls AUR packa

Yet another package manager for Rust.

Rpip Installing. Make sure you have just (packages) installed! Once you have just installed move into the root directory (where this file is) and run

🚀 Supercharge your development with easy to setup package scripts

Mist 🚀 Supercharge your development with easy to setup package scripts. Works with every codebase regardless of the language or framework used! Note:

Owner
✨ amelia chen ✨
✨ amelia chen ✨
A validations framework for doing quality control in studios.

Untitled Checks Framework Overview This framework is designed to provide a system to write checks for studio work. This includes validating assets (ri

Scott Wilson 8 Jan 28, 2023
Enhance low quality images and videos using AI technology.

Real ESRGAN GUI Real ESRGAN GUI is a simple and minimal GUI for xinntao's Real-ESRGAN This allows you to enhance low quality images and videos using A

null 20 Dec 21, 2022
Tight Model format is a lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.

What is Tight Model Format The main goal of the tmf project is to provide a way to save 3D game assets compressed in such a way, that there are no not

null 59 Mar 6, 2023
turbocommit is a Rust-based CLI tool that generates high-quality git commit messages in accordance with the Conventional Commits specification, using OpenAI's

turbocommit is a Rust-based CLI tool that generates high-quality git commit messages in accordance with the Conventional Commits specification, using OpenAI's `gpt-3.5-turbo` language model. It is easy to use and a cost-effective way to keep git commit history at a higher quality, helping developers stay on track with their work.

Sett 16 Mar 26, 2023
An anchor CPI client for the SPL token lending program

anchor-lending anchor-lending is an anchor CPI client for any program that implements or extends the instruction interface found in the spl token lend

Rohan Kapur 11 Oct 24, 2022
Escrow program implemented in Anchor

Anchor Example: Escrow Program See this doc for more implementation details Overview Since this program is extended from the original Escrow Program,

ironaddicteddog 141 Dec 26, 2022
Ah Fuck Anchor

Ah Fuck Anchor

Deep Mehta 24 Dec 14, 2022
Anchor, a Rust Klipper protocol implementation

Anchor Anchor is an implementation of the Klipper protocol. You can use Anchor to create custom Klipper MCUs. It's written in Rust and provides only t

Annex-Engineering 20 Mar 21, 2023
Generates an Anchor CPI crate from a JSON IDL.

anchor-gen Generates a crate for cross-program invocations to an Anchor program from a JSON IDL. Usage In a new crate, write: anchor_gen::generate_cpi

Saber 44 Jul 3, 2023
Game of life rendered in your terminal with over 500+ unique patterns to choose from.

Controls a: play animation n: next generation s: stop j or down arrow: go down next pattern (note: you have to stop the animation to browse the patter

Omar Magdy 20 Dec 22, 2022