2 releases

new 0.2.2-post1 Apr 16, 2025
0.2.2-post0 Mar 17, 2025

#352 in Biology

Download history 75/week @ 2025-03-12 30/week @ 2025-03-19

105 downloads per month

Custom license

135KB
2K SLoC

Rust bindings for Phenopacket Schema.

The crate contains Rust structs and enums generated from Phenopacket Schema protobuf descriptors. Phenopacket Schema versions v1 and v2 are supported.

Examples

Create a Phenopacket Schema element programmatically

Any struct or enum of the schema can be created by invoking its initializer. For instance, an schema::v2::core::OntologyClass:

use phenopackets::schema::v2::core::OntologyClass;

let seizure = OntologyClass {
  id: "HP:0001250".into(),
  label: "Seizure".into(),
};

assert_eq!(&seizure.id, "HP:0001250");
assert_eq!(&seizure.label, "Seizure");

Encode/decode into protobuf binary format

The schema elements can be encoded into or decoded from bytes:

use phenopackets::schema::v2::core::OntologyClass;
use prost::Message;

let seizure = OntologyClass {
  id: "HP:0001250".into(),
  label: "Seizure".into(),
};

// Dump to bytes ...
let bytes: Vec<u8> = seizure.encode_to_vec();

// ... and read back.
let other = OntologyClass::decode(&bytes[..]).unwrap();

assert_eq!(seizure, other);

Note, only the protobuf binary format is implemented (no JSON, YAML, ...).


Continuous Integration Documentation Crate

Rust bindings for Phenopacket Schema

See the documentation on docs.rs for usage examples and more info.

Dependencies

~0.4–2.3MB
~33K SLoC