88use std:: { collections:: HashMap , sync:: Arc } ;
99
1010use indexmap:: IndexSet ;
11- use omicron_uuid_kinds:: { ReconfiguratorSimKind , ReconfiguratorSimUuid } ;
11+ use omicron_uuid_kinds:: {
12+ ReconfiguratorSimStateKind , ReconfiguratorSimStateUuid ,
13+ } ;
1214use typed_rng:: TypedUuidRng ;
1315
1416use crate :: {
@@ -48,8 +50,8 @@ pub struct Simulator {
4850 // In the future, it would be interesting to store a chain of every set of
4951 // heads over time, similar to `jj op log`. That would let us implement undo
5052 // and restore operations.
51- heads : IndexSet < ReconfiguratorSimUuid > ,
52- states : HashMap < ReconfiguratorSimUuid , Arc < SimState > > ,
53+ heads : IndexSet < ReconfiguratorSimStateUuid > ,
54+ states : HashMap < ReconfiguratorSimStateUuid , Arc < SimState > > ,
5355 // This state corresponds to `ROOT_ID`.
5456 //
5557 // Storing it in the Arc is extremely important! `SimStateBuilder` stores a
@@ -59,15 +61,16 @@ pub struct Simulator {
5961 // points to the same memory address.
6062 root_state : Arc < SimState > ,
6163 // Top-level (unversioned) RNG.
62- sim_uuid_rng : TypedUuidRng < ReconfiguratorSimKind > ,
64+ sim_uuid_rng : TypedUuidRng < ReconfiguratorSimStateKind > ,
6365}
6466
6567impl Simulator {
6668 /// The root ID of the store.
6769 ///
6870 /// This is always defined to be the nil UUID, and if queried will always
6971 /// have a state associated with it.
70- pub const ROOT_ID : ReconfiguratorSimUuid = ReconfiguratorSimUuid :: nil ( ) ;
72+ pub const ROOT_ID : ReconfiguratorSimStateUuid =
73+ ReconfiguratorSimStateUuid :: nil ( ) ;
7174
7275 /// Create a new simulator with the given initial seed.
7376 pub fn new ( log : & slog:: Logger , seed : Option < String > ) -> Self {
@@ -77,6 +80,8 @@ impl Simulator {
7780
7881 fn new_inner ( log : & slog:: Logger , seed : String ) -> Self {
7982 let log = log. new ( slog:: o!( "component" => "SimStore" ) ) ;
83+ // The ReconfiguratorSimStateUuid type used to be ReconfiguratorSimUuid.
84+ // Retain the old name in the seed for generated ID compatibility.
8085 let sim_uuid_rng =
8186 TypedUuidRng :: from_seed ( & seed, "ReconfiguratorSimUuid" ) ;
8287 let root_state = SimState :: new_root ( seed) ;
@@ -99,12 +104,15 @@ impl Simulator {
99104
100105 /// Get the current heads of the store.
101106 #[ inline]
102- pub fn heads ( & self ) -> & IndexSet < ReconfiguratorSimUuid > {
107+ pub fn heads ( & self ) -> & IndexSet < ReconfiguratorSimStateUuid > {
103108 & self . heads
104109 }
105110
106111 /// Get the state for the given UUID.
107- pub fn get_state ( & self , id : ReconfiguratorSimUuid ) -> Option < & SimState > {
112+ pub fn get_state (
113+ & self ,
114+ id : ReconfiguratorSimStateUuid ,
115+ ) -> Option < & SimState > {
108116 if id == Self :: ROOT_ID {
109117 return Some ( & self . root_state ) ;
110118 }
@@ -126,7 +134,7 @@ impl Simulator {
126134 fn get_state_by_prefix (
127135 & self ,
128136 prefix : & str ,
129- ) -> Result < ReconfiguratorSimUuid , StateIdResolveError > {
137+ ) -> Result < ReconfiguratorSimStateUuid , StateIdResolveError > {
130138 let mut matching_ids = Vec :: new ( ) ;
131139
132140 if Self :: ROOT_ID . to_string ( ) . starts_with ( prefix) {
@@ -169,11 +177,11 @@ impl Simulator {
169177 }
170178 }
171179
172- /// Resolve a [`ReconfiguratorSimId`] to a [`ReconfiguratorSimUuid `].
180+ /// Resolve a [`ReconfiguratorSimId`] to a [`ReconfiguratorSimStateUuid `].
173181 pub fn resolve_state_id (
174182 & self ,
175183 id : ReconfiguratorSimId ,
176- ) -> Result < ReconfiguratorSimUuid , StateIdResolveError > {
184+ ) -> Result < ReconfiguratorSimStateUuid , StateIdResolveError > {
177185 match id {
178186 ReconfiguratorSimId :: Id ( id) => Ok ( id) ,
179187 ReconfiguratorSimId :: Prefix ( prefix) => {
@@ -192,7 +200,7 @@ impl Simulator {
192200 }
193201
194202 #[ inline]
195- pub ( crate ) fn next_sim_uuid ( & mut self ) -> ReconfiguratorSimUuid {
203+ pub ( crate ) fn next_sim_uuid ( & mut self ) -> ReconfiguratorSimStateUuid {
196204 self . sim_uuid_rng . next ( )
197205 }
198206
0 commit comments