From 970df3ea4169eb2fe935a0f50012503079b8636d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 3 Jan 2020 23:42:37 +0100 Subject: Make channel and network stream behave like the rest. --- src/channel_stream.rs | 33 +++++++++++++++++++++++++++++++++ src/client.rs | 8 -------- src/lib.rs | 4 ++++ src/network_stream.rs | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 src/channel_stream.rs create mode 100644 src/network_stream.rs (limited to 'src') 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 . + */ + +use crate::{ + client::Client, + error::Error, +}; + +pub struct ChannelStream; + +pub fn channel_stream() -> ChannelStream { + ChannelStream {} +} + +impl ChannelStream { + pub fn fetch(&self, client: &Client) -> Result { + 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 { - self.fetch_stream("channel/stream", &()) - } - - pub fn network_stream(&self) -> Result { - self.fetch_stream("network/stream", &()) - } - fn url(&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 . + */ + +use crate::{ + client::Client, + error::Error, +}; + +pub struct NetworkStream; + +pub fn network_stream() -> NetworkStream { + NetworkStream {} +} + +impl NetworkStream { + pub fn fetch(&self, client: &Client) -> Result { + client.fetch_stream("network/stream", &()) + } +} -- cgit v1.2.3