Skip to content

Commit

Permalink
add auto implementation StorageLevel for SimpleStorageType
Browse files Browse the repository at this point in the history
  • Loading branch information
qalisander committed Jun 27, 2024
1 parent 921c86a commit 7bd3fc9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
14 changes: 0 additions & 14 deletions stylus-sdk/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ impl<const B: usize, const L: usize> StorageUint<B, L> {
}
}

unsafe impl<const B: usize, const L: usize> StorageLevel for StorageUint<B, L> {}

impl<const B: usize, const L: usize> StorageType for StorageUint<B, L> {
type Wraps<'a> = Uint<B, L>;
type WrapsMut<'a> = StorageGuardMut<'a, Self>;
Expand Down Expand Up @@ -237,8 +235,6 @@ impl<const B: usize, const L: usize> StorageSigned<B, L> {
}
}

unsafe impl<const B: usize, const L: usize> StorageLevel for StorageSigned<B, L> {}

impl<const B: usize, const L: usize> StorageType for StorageSigned<B, L> {
type Wraps<'a> = Signed<B, L>;
type WrapsMut<'a> = StorageGuardMut<'a, Self>;
Expand Down Expand Up @@ -310,8 +306,6 @@ impl<const N: usize> StorageFixedBytes<N> {
}
}

unsafe impl<const N: usize> StorageLevel for StorageFixedBytes<N> {}

impl<const N: usize> StorageType for StorageFixedBytes<N>
where
ByteCount<N>: SupportedFixedBytes,
Expand Down Expand Up @@ -392,8 +386,6 @@ impl StorageBool {
}
}

unsafe impl StorageLevel for StorageBool {}

impl StorageType for StorageBool {
type Wraps<'a> = bool;
type WrapsMut<'a> = StorageGuardMut<'a, Self>;
Expand Down Expand Up @@ -467,8 +459,6 @@ impl StorageAddress {
}
}

unsafe impl StorageLevel for StorageAddress {}

impl StorageType for StorageAddress {
type Wraps<'a> = Address;
type WrapsMut<'a> = StorageGuardMut<'a, Self>;
Expand Down Expand Up @@ -541,8 +531,6 @@ impl StorageBlockNumber {
}
}

unsafe impl StorageLevel for StorageBlockNumber {}

impl StorageType for StorageBlockNumber {
type Wraps<'a> = BlockNumber;
type WrapsMut<'a> = StorageGuardMut<'a, Self>;
Expand Down Expand Up @@ -615,8 +603,6 @@ impl StorageBlockHash {
}
}

unsafe impl StorageLevel for StorageBlockHash {}

impl StorageType for StorageBlockHash {
type Wraps<'a> = BlockHash;
type WrapsMut<'a> = StorageGuardMut<'a, Self>;
Expand Down
2 changes: 2 additions & 0 deletions stylus-sdk/src/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ pub unsafe trait StorageLevel {
}
}

unsafe impl<'a, T: SimpleStorageType<'a>> StorageLevel for T {}

/// Binds a storage accessor to a lifetime to prevent aliasing.
/// Because this type doesn't implement `DerefMut`, mutable methods on the accessor aren't available.
/// For a mutable accessor, see [`StorageGuardMut`].
Expand Down

0 comments on commit 7bd3fc9

Please sign in to comment.