aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-01-13 23:19:05 +0100
committerGustav Sörnäs <gustav@sornas.net>2021-06-13 12:16:39 +0200
commit54153914d22180777b25a1d4f5089ed2ae2839df (patch)
treeae7ab1272d9dc91511d6b2e788a074eb6dcb3e15
parent42275c61510f38318332a20c1ee41dbc17663b13 (diff)
downloadmum-54153914d22180777b25a1d4f5089ed2ae2839df.tar.gz
de-pub links on mumlib channels
-rw-r--r--mumd/src/state/channel.rs13
-rw-r--r--mumlib/src/state.rs18
2 files changed, 22 insertions, 9 deletions
diff --git a/mumd/src/state/channel.rs b/mumd/src/state/channel.rs
index 6995e1e..2ed05c5 100644
--- a/mumd/src/state/channel.rs
+++ b/mumd/src/state/channel.rs
@@ -169,13 +169,10 @@ pub fn into_channel(
impl From<&Channel> for mumlib::state::Channel {
fn from(channel: &Channel) -> Self {
- mumlib::state::Channel {
- description: channel.description.clone(),
- links: Vec::new(),
- max_users: channel.max_users,
- name: channel.name.clone(),
- children: Vec::new(),
- users: Vec::new(),
- }
+ mumlib::state::Channel::new(
+ channel.name.clone(),
+ channel.description.clone(),
+ channel.max_users,
+ )
}
}
diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs
index 6fad332..772e822 100644
--- a/mumlib/src/state.rs
+++ b/mumlib/src/state.rs
@@ -12,14 +12,30 @@ pub struct Server {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Channel {
pub description: Option<String>,
- pub links: Vec<Vec<usize>>, //to represent several walks through the tree to find channels its linked to
pub max_users: u32,
pub name: String,
pub children: Vec<Channel>,
pub users: Vec<User>,
+
+ links: Vec<Vec<usize>>, //to represent several walks through the tree to find channels its linked to
}
impl Channel {
+ pub fn new(
+ name: String,
+ description: Option<String>,
+ max_users: u32,
+ ) -> Self {
+ Self {
+ description,
+ max_users,
+ name,
+ children: Vec::new(),
+ users: Vec::new(),
+
+ links: Vec::new(),
+ }
+ }
pub fn iter(&self) -> Iter<'_> {
Iter {
me: Some(&self),