use std::{convert::Infallible, fmt::Display, str::FromStr}; use serde::{Deserialize, Serialize}; use crate::{instance::Instance, operation::GiteratedOperation}; use super::GiteratedObject; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ObjectRequest(pub String); #[derive(Serialize, Deserialize, Clone)] pub struct ObjectResponse(pub String); impl GiteratedOperation for ObjectRequest { type Success = ObjectResponse; type Failure = ObjectRequestError; } #[derive(Debug, Clone, thiserror::Error, Serialize, Deserialize)] pub enum ObjectRequestError { #[error("error decoding the object")] Deserialization(String), } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(transparent)] #[repr(transparent)] pub struct NetworkAnyObject(pub String); impl GiteratedObject for NetworkAnyObject { fn object_name() -> &'static str { "any" } fn from_object_str(object_str: &str) -> Result { Ok(Self(object_str.to_string())) } fn home_uri(&self) -> String { todo!() } } impl Display for NetworkAnyObject { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&self.0) } } impl FromStr for NetworkAnyObject { type Err = Infallible; fn from_str(s: &str) -> Result { Ok(Self(s.to_owned())) } }