Store: One Root, Private Memory
What the viewer will understand
- Question When the Shop opens a branch, who owns the new inventory and who can use its data?
- Starting point The viewer knows what a canister and a Rust module are. The film introduces Store,
ModuleMemory,ChildSlot, andChildMapthrough one call. - Takeaway Attachments establish a path from each memory to one actor root. Each memory gives its own module guarded access to private
Data. - Pacing Aim for three minutes. Hold on the new attachment long enough to read its key. The next lesson starts with this branch attached.
The worked example
In RSX's Shop, App::install assembles a detached memory cell with Branches and Settings attached. Store then consumes that cell's ticket to install it as the actor root. Both root slots are occupied when the controller's open_branch(9) calls Branches::open(9) inside root::with. Branches checks that key 9 is absent and its branch limit has room. The inventory constructor creates a detached child with an empty items map. The numbered attachment consumes that ticket and the call returns true. The native test puts the open, item setup and tax setup in one scope. The first two films show the open through the controller endpoint and then pick up with the same branch and data setup. Shop installation · Store::install · Shop endpoints · Branch implementation · Inventory constructor · Shop test
The film gives each SDK operation time to read on screen. The actual controller call executes synchronously in one Store write scope. Store ownership contract
The story in one pass
Shop attaches Branches and Settings to a new cell and installs the assembled tree as the actor root. Follow open(9) into the Branches child map. Inventory arrives with a detached ticket, and the attachment at key 9 consumes it. Hold on that edge, then inspect Inventory's own item map and widen along the attachments to the root.
Components and views
Use the shared visual language and the actual MemoryModule cells and shopMemoryGeometry. The root is on the left, Branches above Settings in the middle, and Inventory to the right of Branches. Each cell shows the same Data and Children compartments and its private MemoryKey badge. A solid attachment runs from a named field in Children to the child's outer boundary. Branches.Children.items is a ChildMap. The items in Inventory's Data is a separate Map<u64, Item> that will hold product records. The ticket is a small Detached slip next to an unattached cell. The slip disappears when an attachment consumes it. Existing Shop drawing · Root slots · Branch child map · Inventory declaration
| View | Framing and anchor |
|---|---|
shop_tree |
One canister, with Actor and the root at left and space for all four memories. Anchor the camera on the root's right edge as its children appear. |
branch_slot |
Branches, the items row and its key 9, plus the entire Inventory position. Frame the path and its two endpoints before the child moves. |
inventory_data |
The full Inventory cell at readable scale. Anchor on its Data border so the key badge, item map, and child compartments stay visible together. |
Scene install_shop — Give the Shop its root
Enters with The canister outline and title. The Shop is about to install.
Beat create_root — Create the cell that will become the root
View and focus shop_tree, starting close on Actor and the root position.
Narration
The Shop installer creates a memory cell for the root. Its own data is empty. The lower compartment holds attachments to child memories. The installer fills those slots before Store installs the root.
Cue and animation On “creates a memory cell”, bring the canonical root cell and its Detached ticket into view just off the root seat. On “The lower compartment”, move emphasis from its Data row () to Children. Mark the Actor position quietly until Store installs the cell.
Leaves with One detached cell with empty branches and settings slots.
Beat attach_initial_children — Fill the named slots
View and focus Widen shop_tree to include the root and both middle cells. Follow the branches row first, then settings.
Narration
The installer attaches Branches to the branches slot, then Settings to the settings slot. Each Child Slot holds at most one child. Store installs the assembled tree as the actor root. Branches can now attach an inventory for each branch number in its Child Map.
Cue and animation On “attaches Branches”, seat the Branches cell and consume its ticket. At “then Settings”, do the same for Settings with tax = 0. At “installs the assembled tree”, settle the assembly in its final position, consume the root ticket and reveal the Actor handle. On “in its Child Map”, hold emphasis on Branches' empty items row.
Leaves with The rooted Branches and Settings cells in their final positions. The Branches child map is empty.
Scene open_inventory — Open branch nine
Enters with The installed tree and the empty Branches child map. The Inventory position has room for a new cell.
Beat locate_branch_key — Check the branch key
View and focus Start at shop_tree and follow the call into branch_slot. End on the items child map and its prospective key 9.
Narration
Open branch nine. Branches checks for that key in its child map and checks that it has room for another branch. Nine is free here. The method asks Inventory to create the memory for that branch inside the current write scope.
Cue and animation On “Open branch nine”, send open_branch(9) into the canister and open(9) to Branches. On “Nine is free here”, use a dashed 9 marker beside the ChildMap to show the key being checked. The solid map entry appears at attach.
Leaves with The key check complete and space for the Inventory cell. Its solid attachment has yet to appear.
Beat create_inventory — Create a detached child
View and focus branch_slot, centered between the absent child entry and the new Inventory cell.
Narration
Inventory uses its private memory key to create a cell with an empty item map. The constructor returns a Detached ticket. Branches can attach that ticket in this write scope.
Cue and animation On “private memory key”, highlight Inventory's key badge as the canonical cell comes into view. Show it just off its final position with the empty items: Map<u64, Item> inside Data. At “returns a Detached ticket”, reveal the slip next to the cell.
Leaves with One detached Inventory cell and its ticket. Key 9 is still absent from the map.
Beat attach_inventory — Attach at key nine
View and focus branch_slot, with the leader endpoint planned at Branches.Children.items[9] on the Branches side of the new edge.
Narration
Branches attaches the inventory at key nine. Attaching consumes the ticket. That entry owns the inventory now. If Branches later takes the attachment out, the child comes back as a Detached ticket. A child left detached retires when the scope finishes.
Cue and animation On “attaches the inventory”, guide the existing cell into its shopMemoryGeometry.inventory seat. Let it arrive before “consumes the ticket”, then remove the slip, turn the dashed 9 into the solid map entry and reveal the ownership edge. Return true after the write scope finishes.
Hold or transition Once the edge and result settle, pause camera and machinery from “That entry owns the inventory now” through the rest of the beat. Point the dashed leader at the map entry. Use the balloon items[9] owns Inventory. The narration's later-take case is an explanation over the attached state. Close the balloon and resume on “Inside the inventory” in the next beat.
Leaves with Branch 9 linked to Inventory and the open operation complete. Taking a branch attachment · Detached lifetime
Scene follow_owner — Follow the attachment to private data
Enters with Branch 9 attached at the end of the open operation.
Beat locate_items_data — Look inside the Inventory owner
View and focus Pan from branch_slot to inventory_data. The ownership edge remains visible at the Inventory boundary as long as framing permits.
Narration
Inside the inventory, the item map will use a product number to find an item. The child map uses a branch number to find the inventory itself. Inventory holds the private key it will need to read or write its data. Branches owns the attachment. Its edge ends at the memory boundary.
Cue and animation On “Inside the inventory”, resume with both cells in the branch_slot frame and emphasize the empty item map. On “a branch number”, pulse key 9 on the ownership edge. On “holds the private key”, point to the key badge in Inventory. On “ends at the memory boundary”, pulse the endpoint of the ownership path. This is a camera inspection of the installed cell. The next film opens its first data guard during setup.
Leaves with The viewer has seen the separate attachment endpoint, owner key and private collection.
Beat trace_root — Widen to one rooted tree
View and focus Widen to shop_tree, anchored on the edges back from Inventory to Branches to Actor.
Narration
Follow the owning edges back from inventory nine, through Branches, to the actor's root. Settings reaches that same root through its own slot. The next checkout will use this inventory for stock and Settings for tax.
Cue and animation On “Follow the owning edges”, trace the two edges upstream in place as the camera widens. On “its own slot”, briefly highlight the Settings attachment. Settle on the full tree with Inventory still empty and both data folders readable at their original positions.
Leaves with The shop_tree end frame that opens the bound-service film.
Review notes
- Listen for a single causal sequence from installation through
open(9)to the actor-root reveal. Test that the termsChildSlotandChildMaphave visible referents on first use. - Check
create_inventoryandattach_inventoryside by side. The same Inventory drawing must move into place, theDetachedticket must be present until the attach, and the ownership line must land on the boundary at key9. - Compare the
open(9)state with its implementation. Branch9ends attached and its collection is empty. Later setup and checkout use the same positions in lesson two. - Scrub the hold with audio muted. The dashed leader lands on
Branches.Children.items[9]and the camera resumes from the frame where it stopped.