You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When implementing an extern function in rigetti/qcs-sdk-rust#515, it occurred to me that an ExternedCall trait is natural in supporting backend functions. That generalization probably belongs in this crate, rather than the respective backend's client SDK.
Implementation may look like the following.
//! This module contains a definition for the [`ExternedCall`] trait.//! Implementations of this trait represent externed functions that//! the a Quil backend supports.//!//! Trait implementations support semantically meaningful interfaces//! that may be converted into Quil [`quil_rs::instruction::Call`]//! instructions as well as their associated `PRAGMA EXTERN`//! instructions.use std::convert::TryInto;use quil_rs::quil::ToQuilError;/// A trait for supporting `PRAGMA EXTERN` and [`quil_rs::instruction::Call`] instructions.pubtraitExternedCall:Sized + TryInto<quil_rs::instruction::Call>{/// An error that may occur when building the signature.typeError:From<ToQuilError>;/// The name of the externed function.constNAME:&'staticstr;/// Build the signature for the externed function. The translation service/// may use this function to check whether user submitted signatures match/// the expected signature.fnbuild_signature() -> Result<quil_rs::instruction::ExternSignature, <SelfasExternedCall>::Error>;/// Build a `PRAGMA EXTERN` instruction for the externed function.fnpragma_extern() -> Result<quil_rs::instruction::Pragma, <SelfasExternedCall>::Error>{use quil_rs::quil::Quil;Ok(quil_rs::instruction::Pragma::new(
quil_rs::instruction::RESERVED_PRAGMA_EXTERN.to_string(),vec![quil_rs::instruction::PragmaArgument::Identifier(Self::NAME.to_string(),)],Some(Self::build_signature()?
.to_quil().map_err(<SelfasExternedCall>::Error::from)?,),))}}
The text was updated successfully, but these errors were encountered:
When implementing an extern function in rigetti/qcs-sdk-rust#515, it occurred to me that an
ExternedCall
trait is natural in supporting backend functions. That generalization probably belongs in this crate, rather than the respective backend's client SDK.Implementation may look like the following.
The text was updated successfully, but these errors were encountered: