aboutsummaryrefslogtreecommitdiffstats
path: root/src/group.rs
diff options
context:
space:
mode:
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())
}
}