- replace from_py_object with derive macro
This commit is contained in:
1 parent
e58b40f9cc
commit
f89e60075c
5 files changed
+70
-50
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ resolver = "3"
|
||||
members = ["ome-metadata", "ome-metadata-derive"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
edition = "2024"
|
||||
rust-version = "1.88.0"
|
||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
[package]
|
||||
name = "ome-metadata-derive"
|
||||
version = "0.6.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.88.0"
|
||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Derive macros for ome-metadata."
|
||||
homepage = "https://git.pomppervova.nl/wim/ome-metadata"
|
||||
repository = "https://git.pomppervova.nl/wim/ome-metadata"
|
||||
documentation = "https://docs.rs/ome-metadata-derive"
|
||||
readme = "README.md"
|
||||
|
||||
|
||||
@@ -94,6 +94,16 @@ pub fn ome_metadata_derive_enum(input: TokenStream) -> TokenStream {
|
||||
let name = input.ident;
|
||||
|
||||
let expanded = quote! {
|
||||
impl<'a, 'py> ::pyo3::FromPyObject<'a, 'py> for #name {
|
||||
type Error = ::pyo3::pyclass::PyClassGuardError<'a, 'py>;
|
||||
|
||||
fn extract(
|
||||
obj: ::pyo3::Borrowed<'a, 'py, ::pyo3::PyAny>,
|
||||
) -> ::std::result::Result<Self, Self::Error> {
|
||||
Ok(*obj.extract::<::pyo3::PyClassGuard<'a, #name>>()?)
|
||||
}
|
||||
}
|
||||
|
||||
impl PyDisplay for #name {
|
||||
fn py_str(&self) -> String {
|
||||
format!("{}", self)
|
||||
@@ -147,6 +157,16 @@ pub fn ome_metadata_derive_unit(input: TokenStream) -> TokenStream {
|
||||
let name = input.ident;
|
||||
|
||||
let expanded = quote! {
|
||||
impl<'a, 'py> ::pyo3::FromPyObject<'a, 'py> for #name {
|
||||
type Error = ::pyo3::pyclass::PyClassGuardError<'a, 'py>;
|
||||
|
||||
fn extract(
|
||||
obj: ::pyo3::Borrowed<'a, 'py, ::pyo3::PyAny>,
|
||||
) -> ::std::result::Result<Self, Self::Error> {
|
||||
Ok(*obj.extract::<::pyo3::PyClassGuard<'a, #name>>()?)
|
||||
}
|
||||
}
|
||||
|
||||
impl PyDisplay for #name {
|
||||
fn py_str(&self) -> String {
|
||||
format!("{}", self)
|
||||
|
||||
+10
-10
@@ -1,17 +1,17 @@
|
||||
[package]
|
||||
name = "ome-metadata"
|
||||
version = "0.6.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.88.0"
|
||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Ome metadata as a rust/python structure."
|
||||
homepage = "https://git.pomppervova.nl/wim/ome-metadata"
|
||||
repository = "https://git.pomppervova.nl/wim/ome-metadata"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
description.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
keywords.workspace = true
|
||||
categories.workspace = true
|
||||
documentation = "https://docs.rs/ome-metadata"
|
||||
readme = "README.md"
|
||||
keywords = ["bioformats", "imread", "ome", "metadata"]
|
||||
categories = ["multimedia::images", "science"]
|
||||
exclude = ["/tests"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
+32
-32
@@ -188,7 +188,7 @@ impl Default for Arc {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ArcType {
|
||||
@@ -249,7 +249,7 @@ impl BinData {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum BinDataCompressionType {
|
||||
@@ -318,7 +318,7 @@ pub enum BinaryFileContent {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum BinningType {
|
||||
@@ -555,7 +555,7 @@ impl Default for Channel {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ChannelAcquisitionModeType {
|
||||
@@ -626,7 +626,7 @@ pub enum ChannelAcquisitionModeType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ChannelContrastMethodType {
|
||||
@@ -669,7 +669,7 @@ pub enum ChannelContrastMethodType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ChannelIlluminationType {
|
||||
@@ -950,7 +950,7 @@ impl Default for DetectorSettings {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum DetectorType {
|
||||
@@ -1252,7 +1252,7 @@ pub struct Experiment {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ExperimentItemType {
|
||||
@@ -1500,7 +1500,7 @@ impl Default for Filament {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum FilamentType {
|
||||
@@ -1686,7 +1686,7 @@ pub struct FilterSet {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum FilterType {
|
||||
@@ -1764,7 +1764,7 @@ pub struct Folder {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum FontFamilyType {
|
||||
@@ -2317,7 +2317,7 @@ impl Default for Laser {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum LaserLaserMediumType {
|
||||
@@ -2410,7 +2410,7 @@ pub enum LaserLaserMediumType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum LaserPulseType {
|
||||
@@ -2447,7 +2447,7 @@ pub enum LaserPulseType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum LaserType {
|
||||
@@ -3003,7 +3003,7 @@ pub struct MapM {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum MarkerType {
|
||||
@@ -3171,7 +3171,7 @@ pub struct MicrobeamManipulation {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum MicrobeamManipulationItemType {
|
||||
@@ -3256,7 +3256,7 @@ pub struct Microscope {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum MicroscopeType {
|
||||
@@ -3291,7 +3291,7 @@ pub enum MicroscopeType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum NamingConventionType {
|
||||
@@ -3522,7 +3522,7 @@ impl Default for Objective {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ObjectiveCorrectionType {
|
||||
@@ -3577,7 +3577,7 @@ pub enum ObjectiveCorrectionType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ObjectiveImmersionType {
|
||||
@@ -3647,7 +3647,7 @@ pub struct ObjectiveSettings {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ObjectiveSettingsMediumType {
|
||||
@@ -3701,7 +3701,7 @@ pub struct OmeBinaryOnly {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum PixelType {
|
||||
@@ -3865,7 +3865,7 @@ impl Pixels {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum PixelsDimensionOrderType {
|
||||
@@ -4892,7 +4892,7 @@ impl Default for ShapeType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ShapeFillRuleType {
|
||||
@@ -4921,7 +4921,7 @@ pub enum ShapeFillRuleType {
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[cfg_attr(
|
||||
feature = "python",
|
||||
pyclass(module = "ome_metadata", from_py_object, get_all, set_all, eq),
|
||||
pyclass(module = "ome_metadata", skip_from_py_object, get_all, set_all, eq),
|
||||
derive(PyOmeEnum)
|
||||
)]
|
||||
pub enum ShapeFontStyleType {
|
||||
@@ -5238,7 +5238,7 @@ impl Default for TransmittanceRange {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
@@ -5293,7 +5293,7 @@ pub enum UnitsElectricPotential {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
@@ -5348,7 +5348,7 @@ pub enum UnitsFrequency {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
@@ -5429,7 +5429,7 @@ pub enum UnitsLength {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
@@ -5484,7 +5484,7 @@ pub enum UnitsPower {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
@@ -5551,7 +5551,7 @@ pub enum UnitsPressure {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
@@ -5592,7 +5592,7 @@ pub enum UnitsTemperature {
|
||||
feature = "python",
|
||||
pyclass(
|
||||
module = "ome_metadata",
|
||||
from_py_object,
|
||||
skip_from_py_object,
|
||||
get_all,
|
||||
set_all,
|
||||
eq,
|
||||
|
||||
Reference in new issue
Block a user