use pyo3::types::PyAnyMethods;
use pyo3::{Bound, FromPyObject, PyAny, PyResult};
use std::ops::Deref;
#[derive(Debug)]
pub struct UniqueId(pub String);
#[derive(Debug)]
pub struct Prompt(pub String);
#[derive(Debug)]
pub struct ExtraPngInfo(pub String);
#[derive(Debug)]
pub struct DynPrompt(pub String);
impl Deref for UniqueId {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'py> FromPyObject<'py> for UniqueId {
fn extract_bound(object: &Bound<'py, PyAny>) -> PyResult<Self> {
object
.extract::<String>()
.map(UniqueId)
}
}
impl<'py> FromPyObject<'py> for Prompt {
fn extract_bound(object: &Bound<'py, PyAny>) -> PyResult<Self> {
Ok(Prompt(object.to_string()))
}
}
impl<'py> FromPyObject<'py> for ExtraPngInfo {
fn extract_bound(object: &Bound<'py, PyAny>) -> PyResult<Self> {
Ok(ExtraPngInfo(object.to_string()))
}
}
impl<'py> FromPyObject<'py> for DynPrompt {
fn extract_bound(object: &Bound<'py, PyAny>) -> PyResult<Self> {
Ok(DynPrompt(object.to_string()))
}
}