aboutsummaryrefslogtreecommitdiffstats
path: root/src/abook.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2023-03-27 22:14:15 +0200
committerHarald Eilertsen <haraldei@anduin.net>2023-03-27 22:14:15 +0200
commitfe9db878e8f7d8f4bff2a51bb49b66ff84013644 (patch)
tree60d040e1f61d5c00e86389578b15a536a212aa43 /src/abook.rs
parent93ee81f05e1cb90c79949d5c57b1d7e3c272dd02 (diff)
downloadrust-zotapi-fe9db878e8f7d8f4bff2a51bb49b66ff84013644.tar.gz
rust-zotapi-fe9db878e8f7d8f4bff2a51bb49b66ff84013644.tar.bz2
rust-zotapi-fe9db878e8f7d8f4bff2a51bb49b66ff84013644.zip
Add ZotAPI trait and derive macro.
The idea is to try to generate more of the boilerplate code, but for now we only do the `z()` method definition. There are also some we're not quite able to replace yet (like XChanRequest) since it also has life times. It's a start anyways :)
Diffstat (limited to 'src/abook.rs')
-rw-r--r--src/abook.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/abook.rs b/src/abook.rs
index d7d38cd..c7ceeb1 100644
--- a/src/abook.rs
+++ b/src/abook.rs
@@ -14,11 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-use crate::{client::Client, error::Error, XChan};
+use crate::{client::Client, error::Error, XChan, ZotAPI};
use serde::Deserialize;
use std::convert::TryFrom;
+use zotapi_derive::ZotAPI;
-#[derive(Debug, Default, Deserialize)]
+#[derive(Debug, Default, Deserialize, ZotAPI)]
pub struct Abook {
#[serde(rename = "abook_id")]
pub id: u32,
@@ -105,12 +106,6 @@ pub struct Abook {
}
-impl Abook {
- pub fn z() -> AbookRequest {
- AbookRequest::default()
- }
-}
-
impl<'a> TryFrom<&'a str> for Abook {
type Error = Error;