Struct wicrs_server::channel::Channel[][src]

pub struct Channel {
    pub id: ID,
    pub hub_id: ID,
    pub name: String,
    pub created: u128,
}

Text channel, used to group a manage sets of messages.

Fields

id: ID

ID of the channel.

hub_id: ID

ID of the Hub that the channel belongs to.

name: String

Name of the channel.

created: u128

Date the channel was created in milliseconds since Unix Epoch.

Implementations

impl Channel[src]

pub fn new(name: String, id: ID, hub_id: ID) -> Self[src]

Creates a new channel object based on parameters.

pub fn get_folder(&self) -> String[src]

Get the path of the channel’s data folder, used for storing message files.

pub async fn create_dir(&self) -> Result<()>[src]

Creates the channel data folder.

pub async fn add_message(&mut self, message: Message) -> Result<()>[src]

Adds a message to the channel, writes it to the file corresponding to the day the message was sent, one file per day of messages, only created if a message is sent that day.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The message file does not exist and could not be created.
  • Was unable to write to the message file.

pub async fn get_last_messages(&self, max: usize) -> Vec<Message>[src]

Gets the last messages sent, max indicates the maximum number of messages to return.

pub async fn get_messages(
    &self,
    from: u128,
    to: u128,
    invert: bool,
    max: usize
) -> Vec<Message>
[src]

Gets a set of messages between two times given in milliseconds since Unix Epoch.

Arguments

  • from - The earliest send time a message can have to be included.
  • to - The latest send time a message can have to be included.
  • invert - If true messages are returned in order of newest to oldest if false, oldest to newest, search is also done in that order.
  • max - The maximum number of messages to return.

pub async fn on_all_raw_lines<F: FnMut(Lines<'_>)>(&self, action: F)[src]

Perform an operation on the raw string of all the lines of all the files in the channel’s data directory.

pub async fn find_messages_containing(
    &self,
    string: String,
    case_sensitive: bool
) -> Vec<Message>
[src]

Search for messages that contain a string, if case_sensitive is true than the search is case_sensitive, case sensitive search is marginally faster.

pub async fn get_message(&self, id: &ID) -> Option<Message>[src]

Get the first message with the given ID.

pub async fn get_current_file(&mut self) -> String[src]

Gets the path of the current message file, filename is time in milliseconds from Unix Epoch divided by 86400000 (the number of milliseconds in a day).

Trait Implementations

impl Clone for Channel[src]

impl Debug for Channel[src]

impl<'de> Deserialize<'de> for Channel[src]

impl PartialEq<Channel> for Channel[src]

impl Serialize for Channel[src]

impl StructuralPartialEq for Channel[src]

Auto Trait Implementations

impl RefUnwindSafe for Channel

impl Send for Channel

impl Sync for Channel

impl Unpin for Channel

impl UnwindSafe for Channel

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,