Skip to content

Commit 5bea4e2

Browse files
author
dj8yf0μl
committed
resolves #1304
1 parent 55bfa40 commit 5bea4e2

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

near-sdk/src/collections/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//! The efficiency of `LookupMap` comes at the cost, since it has fewer methods than `HashMap` and is not
3737
//! that seamlessly integrated with the rest of the Rust standard library.
3838
//!
39-
//! ## Calls to host-functions, used in implementation:
39+
//! ## Calls to **host functions**, used in implementation:
4040
//!
4141
//! * [`near_sdk::env::storage_write`](crate::env::storage_write)
4242
//! * [`near_sdk::env::storage_read`](crate::env::storage_read)

near-sdk/src/lib.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,38 @@ extern crate quickcheck;
147147
/// }
148148
/// ```
149149
///
150-
/// It makes little sense to define
151-
/// contract state without contract-specific methods to view and mutate its state.
150+
/// ### Using SDK collections for storage
151+
///
152+
/// If contract state becomes large, collections from following modules can be used:
153+
///
154+
/// #### [`store`] module:
155+
///
156+
/// ```rust
157+
/// # use near_sdk_macros::near;
158+
/// use near_sdk::store::IterableMap;
159+
///
160+
/// #[near(contract_state)]
161+
/// pub struct StatusMessage {
162+
/// records: IterableMap<String, String>,
163+
/// }
164+
/// ```
165+
///
166+
/// * list of [**host functions**](store#calls-to-host-functions-used-in-implementation) used for [`store`] implementation
167+
/// * **FAQ**: mutating state of collections from [`store`] module is only finally persisted on running [`Drop`/`flush`](store#faq-collections-of-this-module-only-persist-on-drop-and-flush)
168+
///
169+
/// #### [`collections`] module:
170+
///
171+
/// ```rust
172+
/// # use near_sdk_macros::near;
173+
/// use near_sdk::collections::LookupMap;
174+
///
175+
/// #[near(contract_state)]
176+
/// pub struct StatusMessage {
177+
/// records: LookupMap<String, String>,
178+
/// }
179+
/// ```
180+
///
181+
/// * list of [**host functions**](collections#calls-to-host-functions-used-in-implementation) used for [`collections`] implementation
152182
///
153183
/// ## `#[near(serializers=[...])` (annotates structs/enums)
154184
///

near-sdk/src/store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
//! collections to be able to access all values. Because only metadata is serialized, these
8989
//! structures should not be used as a borsh return value from a function.
9090
//!
91-
//! ## Calls to host-functions, used in implementation:
91+
//! ## Calls to **host functions**, used in implementation:
9292
//!
9393
//! * [`near_sdk::env::storage_write`](crate::env::storage_write)
9494
//! * [`near_sdk::env::storage_read`](crate::env::storage_read)

0 commit comments

Comments
 (0)