CQC
A sans-io Rust implementation of the CQC interface.
The Classical-Quantum Combiner (CQC) interface is used to program quantum networking nodes to create, transmit, and manipulate qubits.
The CQC interface will be used to interact with the Dutch demonstration network, currently under development at QuTech in the Netherlands. At present, the CQC interface is supported only by the quantum network simulator Simulaqron.
Principle of Operation
This library provides two functions:
-
Build valid CQC packets.
-
Encode/decode to/from binary format. It is left to the user to decide how best to fit I/O in their framework.
Building Packets
This crate offers two ways of building packets
-
Manually - one can manually build packets using the header definitions and documentation provided in the
hdr
module. -
Using the
builder
module - the builder module provides a simple API for generating CQC packets. It should be used in conjunction with the CQC interface documentation in thehdr
module.
Encoding/decoding packets
All headers in the hdr
module implement serde
's Serialize
and
Deserialize
traits which mean they can be directly used as input to
bincode
. The Encoder
and Decoder
impls provide an example.
The builder
module returns a Request
struct which implements Serialize
which can be used with bincode
.
The library provides a Response
struct which implements Deserialize
and can
be used to deserialize any response from the SimulaQron server.
CQC in action
The following example will create a qubit on one node and send it to another
node. Before running the example below start up the SimulaQron nodes with
$NETSIM/run/startAll.sh --nrnodes 2
.
extern crate bincode;
extern crate cqc;
use builder;
use hdr;
use net;
Design goals
The following goals drive the design of the cqc
crate:
-
The user should be able to create any valid packet
This goal is achieved by having correct struct definitions for the different CQC headers.
-
It should be difficult, though preferably impossible, to create invalid packets
The second goal is achieved by using Rust's typing system as much as possible, especially enums for fields with only a small set of possible values. Furthermore a
builder
module is provided which guarantees correct CQC packets. -
Decoding should raise errors if unrecognised values are detected
This is achieved through a combination of type definitions and deserialization implementations.
-
No assumption about the user's run-time should be made
The library is sans-io and only provides a very plain encoder and decoder as an example. The intention is that the user builds packets using the
cqc
library, but I/O is their responsibility. TheSerialize
andDeserialize
traits are implemented so that the user can simply usebincode
for encode/decode.
Limitations
- Factory and Sequence Headers are not currently fully supported.
- Encode/decode is implemented for client-side operations.
Usage
Add this to your Cargo.toml
:
[]
= "0.3"
and this to your source file:
extern crate cqc;