@@ -64,27 +64,30 @@ pub use bip157::UnboundedReceiver;
6464pub use builder:: BuilderExt ;
6565pub mod builder;
6666
67- /// Client state when idle.
68- pub struct Idle ;
69- /// Client state when subscribed to events.
70- pub struct Subscribed ;
71- /// Client state when active.
72- pub struct Active ;
67+ /// State of the light client.
68+ pub mod state {
69+ /// Client state when idle.
70+ pub struct Idle ;
71+ /// Client state when subscribed to events.
72+ pub struct Subscribed ;
73+ /// Client state when active.
74+ pub struct Active ;
75+ }
7376
7477mod sealed {
7578 pub trait Sealed { }
7679}
7780
78- impl sealed:: Sealed for Idle { }
79- impl sealed:: Sealed for Subscribed { }
80- impl sealed:: Sealed for Active { }
81+ impl sealed:: Sealed for state :: Idle { }
82+ impl sealed:: Sealed for state :: Subscribed { }
83+ impl sealed:: Sealed for state :: Active { }
8184
8285/// State of the client.
8386pub trait State : sealed:: Sealed { }
8487
85- impl State for Idle { }
86- impl State for Subscribed { }
87- impl State for Active { }
88+ impl State for state :: Idle { }
89+ impl State for state :: Subscribed { }
90+ impl State for state :: Active { }
8891
8992/// Subscribe to events, notably
9093#[ derive( Debug ) ]
@@ -115,13 +118,13 @@ pub struct LightClient<S: State> {
115118 _marker : core:: marker:: PhantomData < S > ,
116119}
117120
118- impl LightClient < Idle > {
121+ impl LightClient < state :: Idle > {
119122 fn new (
120123 requester : Requester ,
121124 logging : LoggingSubscribers ,
122125 update : UpdateSubscriber ,
123126 node : bip157:: Node ,
124- ) -> LightClient < Idle > {
127+ ) -> LightClient < state :: Idle > {
125128 LightClient {
126129 requester,
127130 logging_subscribers : Some ( logging) ,
@@ -143,7 +146,7 @@ impl LightClient<Idle> {
143146 pub fn subscribe (
144147 mut self ,
145148 ) -> (
146- LightClient < Subscribed > ,
149+ LightClient < state :: Subscribed > ,
147150 LoggingSubscribers ,
148151 UpdateSubscriber ,
149152 ) {
@@ -162,15 +165,15 @@ impl LightClient<Idle> {
162165 }
163166}
164167
165- impl LightClient < Subscribed > {
168+ impl LightClient < state :: Subscribed > {
166169 /// Start fetching data for the wallet on a dedicated [`tokio::task`]. This will continually
167170 /// run until terminated or no peers could be found.
168171 ///
169172 /// # Panics
170173 ///
171174 /// If there is no [`tokio::runtime::Runtime`] to drive execution. Common in synchronous
172175 /// setups.
173- pub fn start ( mut self ) -> LightClient < Active > {
176+ pub fn start ( mut self ) -> LightClient < state :: Active > {
174177 let node = core:: mem:: take ( & mut self . node ) . expect ( "cannot start twice." ) ;
175178 tokio:: task:: spawn ( async move { node. run ( ) . await } ) ;
176179 LightClient {
@@ -184,7 +187,7 @@ impl LightClient<Subscribed> {
184187
185188 /// Take the underlying node process to run in a custom way. Examples include using a dedicated
186189 /// [`tokio::runtime::Runtime`] or [`tokio::runtime::Handle`] to drive execution.
187- pub fn managed_start ( mut self ) -> ( LightClient < Active > , Node ) {
190+ pub fn managed_start ( mut self ) -> ( LightClient < state :: Active > , Node ) {
188191 let node = core:: mem:: take ( & mut self . node ) . expect ( "cannot start twice." ) ;
189192 let client = LightClient {
190193 requester : self . requester ,
@@ -197,20 +200,20 @@ impl LightClient<Subscribed> {
197200 }
198201}
199202
200- impl LightClient < Active > {
203+ impl LightClient < state :: Active > {
201204 /// The client is active and may now handle requests with a [`Requester`].
202205 pub fn requester ( self ) -> Requester {
203206 self . requester
204207 }
205208}
206209
207- impl From < LightClient < Active > > for Requester {
208- fn from ( value : LightClient < Active > ) -> Self {
210+ impl From < LightClient < state :: Active > > for Requester {
211+ fn from ( value : LightClient < state :: Active > ) -> Self {
209212 value. requester
210213 }
211214}
212215
213- impl AsRef < Requester > for LightClient < Active > {
216+ impl AsRef < Requester > for LightClient < state :: Active > {
214217 fn as_ref ( & self ) -> & Requester {
215218 & self . requester
216219 }
0 commit comments