Skip to content

Commit a51fa39

Browse files
feat: make Executable.get_qcs_client public (#380)
* feat: make Executable.get_qcs_client public * Update crates/lib/src/executable.rs Co-authored-by: Michael Bryant <[email protected]> * chore: follow C-GETTER naming convention advice --------- Co-authored-by: Michael Bryant <[email protected]>
1 parent f4a2418 commit a51fa39

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

crates/lib/src/executable.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,16 @@ impl<'executable> Executable<'executable, '_> {
299299
self
300300
}
301301

302-
/// Load `self.client` if not yet loaded, then return a reference to it.
303-
async fn get_qcs_client(&mut self) -> Result<Arc<Qcs>, Error> {
302+
/// Get a reference to the [`Qcs`] client used by the executable.
303+
///
304+
/// If one has not been set, a default client is loaded, set, and returned.
305+
pub async fn qcs_client(&mut self) -> Arc<Qcs> {
304306
if let Some(client) = &self.qcs_client {
305-
Ok(client.clone())
307+
client.clone()
306308
} else {
307309
let client = Arc::new(Qcs::load().await);
308310
self.qcs_client = Some(client.clone());
309-
Ok(client)
311+
client
310312
}
311313
}
312314
}
@@ -412,7 +414,7 @@ impl<'execution> Executable<'_, 'execution> {
412414
self.quil.clone(),
413415
self.shots,
414416
id,
415-
self.get_qcs_client().await?,
417+
self.qcs_client().await,
416418
self.quilc_client.clone(),
417419
self.compiler_options,
418420
)
@@ -852,7 +854,7 @@ mod describe_qpu_for_id {
852854
"".into(),
853855
shots,
854856
"Aspen-M-3".into(),
855-
exe.get_qcs_client().await.expect("should have client"),
857+
exe.qcs_client().await,
856858
exe.quilc_client.clone(),
857859
CompilerOpts::default(),
858860
)

0 commit comments

Comments
 (0)