aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-01-03 23:42:37 +0100
committerHarald Eilertsen <haraldei@anduin.net>2020-01-03 23:42:37 +0100
commit970df3ea4169eb2fe935a0f50012503079b8636d (patch)
tree4b339e01e957ecf63e7a0d9a67ceabc77496e3d3 /src
parent0c76f0c9727a512475e29b5d099b5b7188f72052 (diff)
downloadrust-zotapi-970df3ea4169eb2fe935a0f50012503079b8636d.tar.gz
rust-zotapi-970df3ea4169eb2fe935a0f50012503079b8636d.tar.bz2
rust-zotapi-970df3ea4169eb2fe935a0f50012503079b8636d.zip
Make channel and network stream behave like the rest.
Diffstat (limited to 'src')
-rw-r--r--src/channel_stream.rs33
-rw-r--r--src/client.rs8
-rw-r--r--src/lib.rs4
-rw-r--r--src/network_stream.rs33
4 files changed, 70 insertions, 8 deletions
diff --git a/src/channel_stream.rs b/src/channel_stream.rs
new file mode 100644
index 0000000..f99ca1c
--- /dev/null
+++ b/src/channel_stream.rs
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 Harald Eilertsen
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+use crate::{
+ client::Client,
+ error::Error,
+};
+
+pub struct ChannelStream;
+
+pub fn channel_stream() -> ChannelStream {
+ ChannelStream {}
+}
+
+impl ChannelStream {
+ pub fn fetch(&self, client: &Client) -> Result<String, Error> {
+ client.fetch_stream("channel/stream", &())
+ }
+}
diff --git a/src/client.rs b/src/client.rs
index dc6cf43..fcafed3 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -43,14 +43,6 @@ impl Client {
}
}
- pub fn channel_stream(&self) -> Result<String, Error> {
- self.fetch_stream("channel/stream", &())
- }
-
- pub fn network_stream(&self) -> Result<String, Error> {
- self.fetch_stream("network/stream", &())
- }
-
fn url<T>(&self, path: &str, args: &T) -> String
where
T: Serialize + std::fmt::Debug,
diff --git a/src/lib.rs b/src/lib.rs
index c4a39c8..d89eb46 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,18 +16,22 @@
mod abconfig;
mod abook;
+mod channel_stream;
mod client;
mod error;
mod group;
mod item;
+mod network_stream;
mod xchan;
pub use abconfig::abconfig;
pub use abook::abook;
+pub use channel_stream::channel_stream;
pub use client::Client;
pub use error::Error;
pub use group::{group, group_members};
pub use item::item;
+pub use network_stream::network_stream;
pub use xchan::xchan;
pub fn client(url: &str, user: &str, pw: &str) -> Client {
diff --git a/src/network_stream.rs b/src/network_stream.rs
new file mode 100644
index 0000000..48a04a7
--- /dev/null
+++ b/src/network_stream.rs
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 Harald Eilertsen
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+use crate::{
+ client::Client,
+ error::Error,
+};
+
+pub struct NetworkStream;
+
+pub fn network_stream() -> NetworkStream {
+ NetworkStream {}
+}
+
+impl NetworkStream {
+ pub fn fetch(&self, client: &Client) -> Result<String, Error> {
+ client.fetch_stream("network/stream", &())
+ }
+}