Skip to content

Commit

Permalink
Rename CwIntKey into IntKey
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Jan 3, 2022
1 parent 6b595b5 commit 6aa82e4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/storage-plus/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::TryInto;

use cosmwasm_std::{Addr, StdError, StdResult};

use crate::int_key::CwIntKey;
use crate::int_key::IntKey;

pub trait KeyDeserialize {
type Output: Sized;
Expand Down
7 changes: 3 additions & 4 deletions packages/storage-plus/src/int_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::mem;
/// but "sign-flipped" (xored msb) big-endian bytes for signed ints.
///
/// So that the representation of signed integers is in the right lexicographical order.
// TODO: Rename to `IntKey` after deprecating current `IntKey` (https://github.com/CosmWasm/cw-plus/issues/570)
pub trait CwIntKey: Sized + Copy {
pub trait IntKey: Sized + Copy {
type Buf: AsRef<[u8]> + AsMut<[u8]> + Into<Vec<u8>> + Default;

fn to_cw_bytes(&self) -> Self::Buf;
Expand All @@ -14,7 +13,7 @@ pub trait CwIntKey: Sized + Copy {

macro_rules! cw_uint_keys {
(for $($t:ty),+) => {
$(impl CwIntKey for $t {
$(impl IntKey for $t {
type Buf = [u8; mem::size_of::<$t>()];

#[inline]
Expand All @@ -34,7 +33,7 @@ cw_uint_keys!(for u8, u16, u32, u64, u128);

macro_rules! cw_int_keys {
(for $($t:ty, $ut:ty),+) => {
$(impl CwIntKey for $t {
$(impl IntKey for $t {
type Buf = [u8; mem::size_of::<$t>()];

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cosmwasm_std::Addr;

use crate::de::KeyDeserialize;
use crate::helpers::namespaces_with_key;
use crate::int_key::CwIntKey;
use crate::int_key::IntKey;

#[derive(Debug)]
pub enum Key<'a> {
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub use indexes::MultiIndex;
pub use indexes::UniqueIndex;
#[cfg(feature = "iterator")]
pub use indexes::{index_string, index_string_tuple, index_triple, index_tuple, Index};
pub use int_key::CwIntKey;
pub use int_key::IntKey;
pub use item::Item;
pub use keys::{Key, Prefixer, PrimaryKey};
pub use keys_old::IntKeyOld;
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ mod test {
#[cfg(feature = "iterator")]
use cosmwasm_std::{Order, StdResult};

use crate::int_key::CwIntKey;
use crate::int_key::IntKey;
use crate::keys_old::IntKeyOld;

#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
Expand Down
6 changes: 3 additions & 3 deletions packages/storage-plus/src/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::ops::Deref;

use crate::de::KeyDeserialize;
use crate::helpers::{namespaces_with_key, nested_namespaces_with_key};
use crate::int_key::CwIntKey;
use crate::int_key::IntKey;
use crate::iter_helpers::{concat, deserialize_kv, deserialize_v, trim};
use crate::keys::Key;
use crate::{Endian, Prefixer};
Expand All @@ -35,12 +35,12 @@ impl Bound {
}

/// Turns an int, like Option<u32> into an inclusive bound
pub fn inclusive_int<T: CwIntKey + Endian>(limit: T) -> Self {
pub fn inclusive_int<T: IntKey + Endian>(limit: T) -> Self {
Bound::Inclusive(limit.to_cw_bytes().into())
}

/// Turns an int, like Option<u64> into an exclusive bound
pub fn exclusive_int<T: CwIntKey + Endian>(limit: T) -> Self {
pub fn exclusive_int<T: IntKey + Endian>(limit: T) -> Self {
Bound::Exclusive(limit.to_cw_bytes().into())
}
}
Expand Down

0 comments on commit 6aa82e4

Please sign in to comment.