Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "2"
members = [
"collections",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To go with these changes, can you include the new package at

SBPF_PROGRAM_PACKAGES: "['discriminator', 'generic-token', 'list-view', 'pod', 'program-error', 'tlv-account-resolution', 'type-length-value']"
RUST_PACKAGES: "['discriminator', 'discriminator-derive', 'discriminator-syn', 'generic-token', 'generic-token-tests', 'list-view', 'pod', 'program-error', 'program-error-derive', 'tlv-account-resolution', 'type-length-value', 'type-length-value-derive', 'type-length-value-derive-test']"
WASM_PACKAGES: "['discriminator', 'generic-token', 'list-view', 'pod', 'program-error', 'tlv-account-resolution', 'type-length-value']"
and ?

"discriminator",
"discriminator-derive",
"discriminator-syn",
Expand Down
29 changes: 29 additions & 0 deletions collections/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "spl-collections"
version = "0.0.0"
description = "Serialization-aware collection wrappers for Solana account data"
authors = ["Anza Maintainers <maintainers@anza.xyz>"]
repository = "https://github.com/solana-program/libraries"
license = "Apache-2.0"
edition = "2021"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
all-features = true
rustdoc-args = ["--cfg=docsrs"]

[features]
alloc = []
borsh = ["dep:borsh", "alloc"]
default = ["alloc"]
wincode = ["dep:wincode", "alloc"]

[dependencies]
borsh = { version = "1.0", features = ["derive"], default-features = false, optional = true }
wincode = { version = "0.4.4", features = ["alloc", "derive"], default-features = false, optional = true }

[dev-dependencies]
spl-collections = { path = ".", features = ["borsh", "wincode"] }

[lib]
crate-type = ["lib"]
21 changes: 21 additions & 0 deletions collections/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Serialization-aware collection wrappers for Solana account data.
//!
//! This crate provides wrappers around collection types to support custom serialization
//! logic. This is useful for programs that have specific requirements for how data is
//! stored.

#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "alloc")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should depend on alloc by default so we can avoid having so many #[cfg(feature = "alloc")]. Currently both types require alloc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine by me, we could even call the crate spl-alloc if we want to try something else 😅

extern crate alloc;

#[cfg(feature = "alloc")]
mod string;
#[cfg(feature = "alloc")]
mod vec;

#[cfg(feature = "alloc")]
pub use string::*;
#[cfg(feature = "alloc")]
pub use vec::*;
Loading