Skip to main content

nextcloud_ocs/envelope/
body.rs

1use serde::{Deserialize, Serialize};
2
3use super::Meta;
4
5/// The `ocs` object of an OCS response: [`Meta`] plus the endpoint payload.
6///
7/// `data` is kept as the endpoint's own type so callers decode straight into
8/// a domain struct instead of walking a generic JSON value.
9#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
10pub struct Ocs<T> {
11    meta: Meta,
12    data: T,
13}
14
15impl<T> Ocs<T> {
16    /// Verdict and pagination hints for this response.
17    pub const fn meta(&self) -> &Meta {
18        &self.meta
19    }
20
21    /// Payload returned by the endpoint.
22    pub const fn data(&self) -> &T {
23        &self.data
24    }
25
26    /// Consumes the response, yielding the payload.
27    pub fn into_data(self) -> T {
28        self.data
29    }
30}