aboutsummaryrefslogtreecommitdiffstats
path: root/src/group.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-01-03 23:32:44 +0100
committerHarald Eilertsen <haraldei@anduin.net>2020-01-03 23:32:44 +0100
commit0c76f0c9727a512475e29b5d099b5b7188f72052 (patch)
treed1c2b59458c62116447fa2d885113afe6a5378da /src/group.rs
parent5f96d9981a6d041f5c8a464cda10a0dc371060f8 (diff)
downloadrust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.tar.gz
rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.tar.bz2
rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.zip
Move Client out of the api objects.
Also make constructor functions in the zotapi namespace.
Diffstat (limited to 'src/group.rs')
-rw-r--r--src/group.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/group.rs b/src/group.rs
index 9135425..e17addb 100644
--- a/src/group.rs
+++ b/src/group.rs
@@ -20,17 +20,15 @@ use crate::{
};
use serde::Serialize;
-pub struct GroupFetcher<'a> {
- client: &'a Client,
-}
+pub struct Group;
-impl<'a> GroupFetcher<'a> {
- pub fn new(client: &'a Client) -> GroupFetcher<'a> {
- GroupFetcher { client }
- }
+pub fn group() -> Group {
+ Group { }
+}
- pub fn fetch(&self) -> Result<String, Error> {
- self.client.fetch_stream("group", &())
+impl Group {
+ pub fn fetch(&self, client: &Client) -> Result<String, Error> {
+ client.fetch_stream("group", &())
}
}
@@ -43,27 +41,26 @@ enum GroupSelector<'a> {
Name(&'a str),
}
-pub struct GroupMembersFetcher<'a> {
- client: &'a Client,
+pub struct GroupMembers<'a> {
id: Option<GroupSelector<'a>>,
}
-impl<'a> GroupMembersFetcher<'a> {
- pub fn new(client: &'a Client) -> GroupMembersFetcher<'a> {
- GroupMembersFetcher { client, id: None }
- }
+pub fn group_members<'a>() -> GroupMembers<'a> {
+ GroupMembers { id: None }
+}
- pub fn by_group_id(&mut self, id: u64) -> &GroupMembersFetcher<'a> {
+impl<'a> GroupMembers<'a> {
+ pub fn by_group_id(&mut self, id: u64) -> &GroupMembers<'a> {
self.id = Some(GroupSelector::Id(id));
self
}
- pub fn by_group_name(&mut self, name: &'a str) -> &GroupMembersFetcher<'a> {
+ pub fn by_group_name(&mut self, name: &'a str) -> &GroupMembers<'a> {
self.id = Some(GroupSelector::Name(name));
self
}
- pub fn fetch(&self) -> Result<String, Error> {
- self.client.fetch_stream("group_members", &self.id.as_ref().unwrap())
+ pub fn fetch(&self, client: &Client) -> Result<String, Error> {
+ client.fetch_stream("group_members", &self.id.as_ref().unwrap())
}
}