Skip to content

Commit

Permalink
desktop/request: Relax trait conditions on Response
Browse files Browse the repository at this point in the history
Make it usable in backend side without unnecessarily implement Serialize
when not needed
  • Loading branch information
bilelmoussaoui committed Aug 10, 2024
1 parent ebfdc2f commit 0fef5ca
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/desktop/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,15 @@ use crate::{desktop::HandleToken, proxy::Proxy, Error};
/// of a [`Request`].
#[derive(Debug, Type)]
#[zvariant(signature = "(ua{sv})")]
pub enum Response<T>
where
T: for<'de> Deserialize<'de> + Type,
{
pub enum Response<T> {
/// Success, the request is carried out.
Ok(T),
/// The user cancelled the request or something else happened.
Err(ResponseError),
}

#[cfg(feature = "backend")]
impl<T> Response<T>
where
T: for<'de> Deserialize<'de> + Type,
{
impl<T> Response<T> {
/// The corresponding response type.
pub fn response_type(self) -> ResponseType {
match self {
Expand Down Expand Up @@ -113,7 +107,7 @@ where

impl<T> Serialize for Response<T>
where
T: for<'de> Deserialize<'de> + Serialize + Type,
T: Serialize + Type,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -135,10 +129,7 @@ where
}

#[doc(hidden)]
impl<T> From<(ResponseType, Option<T>)> for Response<T>
where
T: for<'de> Deserialize<'de> + Type,
{
impl<T> From<(ResponseType, Option<T>)> for Response<T> {
fn from(f: (ResponseType, Option<T>)) -> Self {
match f.0 {
ResponseType::Success => {
Expand Down

0 comments on commit 0fef5ca

Please sign in to comment.