#![allow(missing_docs)]
use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct VMRecord {
pub vm_name: String,
pub ssh_dest: String,
pub https_url: String,
pub status: String,
pub region: String,
pub region_display: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub created_at: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub egress_policy: Option<EgressPolicy>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct VMListResponse {
pub vms: Vec<VMRecord>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhoamiSSHKey {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
pub public_key: String,
pub fingerprint: String,
pub current: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WhoamiResponse {
pub email: String,
pub region: String,
pub region_display: String,
pub ssh_keys: Vec<WhoamiSSHKey>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct StatPoint {
pub timestamp: String,
pub vm_name: String,
pub cpu_cores: f64,
pub cpu_nominal: f64,
pub mem_used_bytes: i64,
pub mem_total_bytes: i64,
pub disk_size_gb: f64,
pub disk_used_gb: f64,
pub disk_logical_used_gb: f64,
pub fs_used_gb: f64,
pub fs_total_gb: f64,
pub fs_free_gb: f64,
pub fs_available_gb: f64,
pub network_tx_mbps: f64,
pub network_rx_mbps: f64,
pub io_read_mbps: f64,
pub io_write_mbps: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct StatResponse {
pub name: String,
pub status: String,
pub range: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub points: Option<Vec<StatPoint>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct NewResponse {
pub vm_name: String,
pub tags: Vec<String>,
pub ssh_command: String,
pub ssh_dest: String,
pub ssh_host: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ssh_user: Option<String>,
pub ssh_port: i64,
pub https_url: String,
pub proxy_port: i64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub shelley_url: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vscode_url: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub xterm_url: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
pub created_at: String,
pub egress_policy: EgressPolicy,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pool_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub standalone: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CpResponse {
pub name: String,
pub state: String,
pub source: String,
pub ssh: String,
pub ssh_host: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ssh_user: Option<String>,
pub https_url: String,
pub tags: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub created_at: Option<String>,
pub egress_policy: EgressPolicy,
pub elapsed: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pool_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pool_name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub standalone: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RmResponse {
pub deleted: Vec<String>,
pub failed: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub not_found: Option<Vec<String>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub errors: Option<BTreeMap<String, String>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RestartResponse {
pub status: String,
pub vm_name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RenameResponse {
pub status: String,
pub old_name: String,
pub new_name: String,
pub ssh_dest: String,
pub https_url: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PauseResponse {
pub vm_name: String,
pub status: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ResumeResponse {
pub vm_name: String,
pub status: String,
#[serde(with = "bool_string")]
pub cold_booted: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DiskResizeRequest {
pub status: DiskResizeStatus,
pub requested_disk_bytes: i64,
pub requested_at: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub resolved_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ResizeResponse {
pub vm_name: String,
pub restart_required: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub old_memory: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub new_memory: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub old_cpus: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub new_cpus: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub disk_old_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub disk_new_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub disk_resize_pending_approval: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub disk_capacity_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub requested_disk_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub self_serve_max_disk_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub approval_max_disk_bytes: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub approval_reasons: Option<Vec<String>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub disk_resize_request: Option<DiskResizeRequest>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct EgressResponse {
pub vm_name: String,
pub egress_policy: EgressPolicy,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct GenerateAPIKeyResponse {
pub label: String,
pub token: String,
pub namespace: String,
pub fingerprint: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub expires_at: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ips: Option<Vec<String>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CommentResponse {
pub vm_name: String,
pub comment: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TagResponse {
pub vm_name: String,
pub tags: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DomainAdded {
pub vm_name: String,
pub domain: String,
pub wildcard: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub wildcard_base: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pattern: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DomainAddDNSMismatch {
pub error: String,
pub vm_name: String,
pub domain: String,
pub expected: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DomainAddDelegationMissing {
pub error: String,
pub vm_name: String,
pub domain: String,
pub wildcard_base: String,
pub delegation_name: String,
pub delegation_target: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum DomainAddResponse {
DomainAddDelegationMissing(DomainAddDelegationMissing),
DomainAddDNSMismatch(DomainAddDNSMismatch),
DomainAdded(DomainAdded),
Other(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DomainRmResponse {
pub vm_name: String,
pub domain: String,
pub removed: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareUser {
pub email: String,
pub status: ShareUserStatus,
pub invited_at: String,
pub share_level: ShareLevel,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareLink {
pub token: String,
pub created_at: String,
pub use_count: i64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub last_used_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareTeam {
pub team_id: String,
pub team_name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareSSOClaim {
pub name: String,
pub value: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareSSO {
pub active: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub issuer: Option<String>,
pub claim: ShareSSOClaim,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareShowResponse {
pub vm_name: String,
pub status: Visibility,
pub port: i64,
pub url: String,
pub users: Vec<ShareUser>,
pub links: Vec<ShareLink>,
pub teams: Vec<ShareTeam>,
pub team_access: bool,
pub team_ssh: bool,
pub team_shelley: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub support_has_root: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub forward_access_token: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sso: Option<ShareSSO>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareRoute {
pub vm_name: String,
pub port: i64,
pub share: Visibility,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareRouteUpdate {
pub vm_name: String,
pub port: i64,
pub share: Visibility,
pub status: String,
pub team_access: bool,
pub team_ssh: bool,
pub team_shelley: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum SharePortResponse {
ShareRouteUpdate(ShareRouteUpdate),
ShareRoute(ShareRoute),
Other(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareInvite {
pub status: String,
pub vm_name: String,
pub shared_with: String,
pub url: String,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareTeamChange {
pub status: String,
pub vm_name: String,
pub team_name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareMessage {
pub status: String,
pub vm_name: String,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareRootChange {
pub status: String,
pub vm_name: String,
pub shared_with: String,
pub share_level: ShareLevel,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareTeamRootChange {
pub status: String,
pub vm_name: String,
pub team_access: bool,
pub team_ssh: bool,
pub team_shelley: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ShareAddResponse {
ShareInvite(ShareInvite),
ShareTeamRootChange(ShareTeamRootChange),
ShareRootChange(ShareRootChange),
ShareTeamChange(ShareTeamChange),
ShareMessage(ShareMessage),
Other(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ShareRemoveResponse {
ShareTeamRootChange(ShareTeamRootChange),
ShareRootChange(ShareRootChange),
ShareTeamChange(ShareTeamChange),
ShareMessage(ShareMessage),
Other(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShareLinkCreated {
pub status: String,
pub vm_name: String,
pub token: String,
pub url: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReceiveEmailStatus {
pub vm_name: String,
pub email_enabled: bool,
pub email_address: String,
pub reply_policy: ReplyPolicy,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReceiveEmailChange {
pub status: String,
pub vm_name: String,
pub email_enabled: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub email_address: Option<String>,
pub reply_policy: ReplyPolicy,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ShareReceiveEmailResponse {
ReceiveEmailChange(ReceiveEmailChange),
ReceiveEmailStatus(ReceiveEmailStatus),
Other(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShelleyInstalled {
pub vm_name: String,
pub status: String,
pub backup: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ShelleyNotInstalled {
pub error: String,
pub message: String,
pub download_url: String,
pub arch: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ShelleyInstallResponse {
ShelleyNotInstalled(ShelleyNotInstalled),
ShelleyInstalled(ShelleyInstalled),
Other(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum EgressPolicy {
Integrations,
All,
Other(String),
}
impl EgressPolicy {
pub fn as_str(&self) -> &str {
match self {
Self::Integrations => "integrations",
Self::All => "all",
Self::Other(s) => s,
}
}
}
impl std::fmt::Display for EgressPolicy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<&str> for EgressPolicy {
fn from(s: &str) -> Self {
match s {
"integrations" => Self::Integrations,
"all" => Self::All,
_ => Self::Other(s.to_string()),
}
}
}
impl Serialize for EgressPolicy {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for EgressPolicy {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
Ok(Self::from(String::deserialize(d)?.as_str()))
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum DiskResizeStatus {
Pending,
Approved,
Rejected,
Superseded,
Cancelled,
Other(String),
}
impl DiskResizeStatus {
pub fn as_str(&self) -> &str {
match self {
Self::Pending => "pending",
Self::Approved => "approved",
Self::Rejected => "rejected",
Self::Superseded => "superseded",
Self::Cancelled => "cancelled",
Self::Other(s) => s,
}
}
}
impl std::fmt::Display for DiskResizeStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<&str> for DiskResizeStatus {
fn from(s: &str) -> Self {
match s {
"pending" => Self::Pending,
"approved" => Self::Approved,
"rejected" => Self::Rejected,
"superseded" => Self::Superseded,
"cancelled" => Self::Cancelled,
_ => Self::Other(s.to_string()),
}
}
}
impl Serialize for DiskResizeStatus {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for DiskResizeStatus {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
Ok(Self::from(String::deserialize(d)?.as_str()))
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ShareUserStatus {
Pending,
Active,
Other(String),
}
impl ShareUserStatus {
pub fn as_str(&self) -> &str {
match self {
Self::Pending => "pending",
Self::Active => "active",
Self::Other(s) => s,
}
}
}
impl std::fmt::Display for ShareUserStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<&str> for ShareUserStatus {
fn from(s: &str) -> Self {
match s {
"pending" => Self::Pending,
"active" => Self::Active,
_ => Self::Other(s.to_string()),
}
}
}
impl Serialize for ShareUserStatus {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for ShareUserStatus {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
Ok(Self::from(String::deserialize(d)?.as_str()))
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ShareLevel {
Web,
Root,
Other(String),
}
impl ShareLevel {
pub fn as_str(&self) -> &str {
match self {
Self::Web => "web",
Self::Root => "root",
Self::Other(s) => s,
}
}
}
impl std::fmt::Display for ShareLevel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<&str> for ShareLevel {
fn from(s: &str) -> Self {
match s {
"web" => Self::Web,
"root" => Self::Root,
_ => Self::Other(s.to_string()),
}
}
}
impl Serialize for ShareLevel {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for ShareLevel {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
Ok(Self::from(String::deserialize(d)?.as_str()))
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Visibility {
Public,
Private,
Other(String),
}
impl Visibility {
pub fn as_str(&self) -> &str {
match self {
Self::Public => "public",
Self::Private => "private",
Self::Other(s) => s,
}
}
}
impl std::fmt::Display for Visibility {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<&str> for Visibility {
fn from(s: &str) -> Self {
match s {
"public" => Self::Public,
"private" => Self::Private,
_ => Self::Other(s.to_string()),
}
}
}
impl Serialize for Visibility {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for Visibility {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
Ok(Self::from(String::deserialize(d)?.as_str()))
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ReplyPolicy {
All,
Known,
Owner,
None,
Other(String),
}
impl ReplyPolicy {
pub fn as_str(&self) -> &str {
match self {
Self::All => "all",
Self::Known => "known",
Self::Owner => "owner",
Self::None => "none",
Self::Other(s) => s,
}
}
}
impl std::fmt::Display for ReplyPolicy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<&str> for ReplyPolicy {
fn from(s: &str) -> Self {
match s {
"all" => Self::All,
"known" => Self::Known,
"owner" => Self::Owner,
"none" => Self::None,
_ => Self::Other(s.to_string()),
}
}
}
impl Serialize for ReplyPolicy {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for ReplyPolicy {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
Ok(Self::from(String::deserialize(d)?.as_str()))
}
}
mod bool_string {
use serde::{Deserialize, Deserializer, Serializer};
pub fn serialize<S: Serializer>(value: &bool, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(if *value { "true" } else { "false" })
}
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<bool, D::Error> {
#[derive(Deserialize)]
#[serde(untagged)]
enum Repr {
Bool(bool),
String(String),
}
match Repr::deserialize(d)? {
Repr::Bool(b) => Ok(b),
Repr::String(s) if s == "true" => Ok(true),
Repr::String(s) if s == "false" => Ok(false),
Repr::String(s) => Err(serde::de::Error::custom(format!("expected \"true\" or \"false\", not {s:?}"))),
}
}
}