Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on:

env:
JS_PACKAGES: "['type-length-value-js']"
SBPF_PROGRAM_PACKAGES: "['discriminator', 'generic-token', 'pod', 'program-error', 'tlv-account-resolution', 'type-length-value']"
RUST_PACKAGES: "['discriminator', 'discriminator-derive', 'discriminator-syn', 'generic-token', 'generic-token-tests', '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', 'pod', 'program-error', 'tlv-account-resolution', 'type-length-value']"
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']"

jobs:
set_env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- discriminator-derive
- discriminator-syn
- generic-token
- list-view
- pod
- program-error
- program-error-derive
Expand Down
19 changes: 15 additions & 4 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
Expand Up @@ -6,6 +6,7 @@ members = [
"discriminator-syn",
"generic-token",
"generic-token-tests",
"list-view",
"pod",
"program-error",
"program-error-derive",
Expand Down
19 changes: 19 additions & 0 deletions list-view/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "spl-list-view"
version = "0.1.0"
description = "ListView: a zero-copy, variable-length array view"
authors = ["Anza Maintainers <maintainers@anza.xyz>"]
repository = "https://github.com/solana-program/libraries"
license = "Apache-2.0"
edition = "2021"

[dependencies]
bytemuck = "1.25.0"
solana-program-error = "3.0.0"
spl-pod = { version = "0.7.2", path = "../pod" }

[dev-dependencies]
bytemuck_derive = "1.10.2"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
File renamed without changes.
6 changes: 2 additions & 4 deletions pod/src/list/list_trait.rs → list-view/src/list_trait.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use {
crate::{list::ListView, pod_length::PodLength},
bytemuck::Pod,
core::ops::Deref,
solana_program_error::ProgramError,
crate::ListView, bytemuck::Pod, core::ops::Deref, solana_program_error::ProgramError,
spl_pod::pod_length::PodLength,
};

/// A trait to abstract the shared, read-only behavior
Expand Down
24 changes: 11 additions & 13 deletions pod/src/list/list_view.rs → list-view/src/list_view.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
//! `ListView`, a compact, zero-copy array wrapper.

use {
crate::{
bytemuck::{
pod_from_bytes, pod_from_bytes_mut, pod_slice_from_bytes, pod_slice_from_bytes_mut,
},
error::PodSliceError,
list::{list_view_mut::ListViewMut, list_view_read_only::ListViewReadOnly},
pod_length::PodLength,
primitives::PodU32,
},
crate::{list_view_mut::ListViewMut, list_view_read_only::ListViewReadOnly},
bytemuck::Pod,
core::{
marker::PhantomData,
mem::{align_of, size_of},
ops::Range,
},
solana_program_error::ProgramError,
spl_pod::{
bytemuck::{
pod_from_bytes, pod_from_bytes_mut, pod_slice_from_bytes, pod_slice_from_bytes_mut,
},
error::PodSliceError,
pod_length::PodLength,
primitives::PodU32,
},
};

/// An API for interpreting a raw buffer (`&[u8]`) as a variable-length collection of Pod elements.
Expand Down Expand Up @@ -185,11 +185,9 @@ impl<T: Pod, L: PodLength> ListView<T, L> {
mod tests {
use {
super::*,
crate::{
list::List,
primitives::{PodU128, PodU16, PodU32, PodU64},
},
crate::List,
bytemuck_derive::{Pod as DerivePod, Zeroable},
spl_pod::primitives::{PodU128, PodU16, PodU32, PodU64},
};

#[test]
Expand Down
11 changes: 4 additions & 7 deletions pod/src/list/list_view_mut.rs → list-view/src/list_view_mut.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//! `ListViewMut`, a mutable, compact, zero-copy array wrapper.

use {
crate::{
error::PodSliceError, list::list_trait::List, pod_length::PodLength, primitives::PodU32,
},
crate::list_trait::List,
bytemuck::Pod,
core::ops::{Deref, DerefMut},
solana_program_error::ProgramError,
spl_pod::{error::PodSliceError, pod_length::PodLength, primitives::PodU32},
};

#[derive(Debug)]
Expand Down Expand Up @@ -82,11 +81,9 @@ impl<T: Pod, L: PodLength> List for ListViewMut<'_, T, L> {
mod tests {
use {
super::*,
crate::{
list::{List, ListView},
primitives::{PodU16, PodU32, PodU64},
},
crate::{List, ListView},
bytemuck_derive::{Pod, Zeroable},
spl_pod::primitives::{PodU16, PodU32, PodU64},
};

#[repr(C)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! `ListViewReadOnly`, a read-only, compact, zero-copy array wrapper.

use {
crate::{list::list_trait::List, pod_length::PodLength, primitives::PodU32},
crate::list_trait::List,
bytemuck::Pod,
core::ops::Deref,
spl_pod::{pod_length::PodLength, primitives::PodU32},
};

#[derive(Debug)]
Expand Down Expand Up @@ -35,13 +36,13 @@ impl<T: Pod, L: PodLength> Deref for ListViewReadOnly<'_, T, L> {
mod tests {
use {
super::*,
crate::{
list::ListView,
crate::ListView,
bytemuck_derive::{Pod as DerivePod, Zeroable},
core::mem::size_of,
spl_pod::{
pod_length::PodLength,
primitives::{PodU32, PodU64},
},
bytemuck_derive::{Pod as DerivePod, Zeroable},
core::mem::size_of,
};

#[repr(C, align(16))]
Expand Down
2 changes: 0 additions & 2 deletions pod/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

pub mod bytemuck;
pub mod error;
pub mod list;
pub mod option;
pub mod optional_keys;
pub mod pod_length;
pub mod primitives;
pub mod slice;

// Export current sdk types for downstream users building with a different sdk
// version
Expand Down
Loading
Loading