Struct deltachat::chat::ChatId

source ·
pub struct ChatId(u32);
Expand description

Chat ID, including reserved IDs.

Some chat IDs are reserved to identify special chat types. This type can represent both the special as well as normal chats.

Tuple Fields§

§0: u32

Implementations§

source§

impl ChatId

source

pub const fn new(id: u32) -> ChatId

Create a new ChatId.

source

pub fn is_unset(self) -> bool

An unset ChatId

This is transitional and should not be used in new code.

source

pub fn is_special(self) -> bool

Whether the chat ID signifies a special chat.

This kind of chat ID can not be used for real chats.

source

pub fn is_trash(self) -> bool

Chat ID for messages which need to be deleted.

Messages which should be deleted get this chat ID and are deleted later. Deleted messages need to stay around as long as they are not deleted on the server so that their rfc724_mid remains known and downloading them again can be avoided.

Chat ID signifying there are any number of archived chats.

This chat ID can be returned in a Chatlist and signals to the UI to include a link to the archived chats.

source

pub fn is_alldone_hint(self) -> bool

Virtual chat ID signalling there are only archived chats.

This can be included in the chatlist if the DC_GCL_ADD_ALLDONE_HINT flag is used to build the Chatlist.

source

pub(crate) fn lookup_by_message(msg: &Message) -> Option<Self>

Returns ChatId of a chat that msg belongs to.

Checks that msg is assigned to the right chat.

source

pub async fn lookup_by_contact( context: &Context, contact_id: ContactId ) -> Result<Option<Self>>

Returns the ChatId for the 1:1 chat with contact_id if it exists and is not blocked.

If the chat does not exist or is blocked, None is returned.

source

pub(crate) async fn get_for_contact( context: &Context, contact_id: ContactId ) -> Result<Self>

Returns the ChatId for the 1:1 chat with contact_id.

If the chat does not yet exist an unblocked chat (Blocked::Not) is created.

This is an internal API, if a user action needs to get a chat ChatId::create_for_contact should be used as this also scales up the Contact’s origin.

source

pub async fn create_for_contact( context: &Context, contact_id: ContactId ) -> Result<Self>

Returns the unblocked 1:1 chat with contact_id.

This should be used when a user action creates a chat 1:1, it ensures the chat exists, is unblocked and scales the Contact’s origin.

source

pub(crate) async fn create_for_contact_with_blocked( context: &Context, contact_id: ContactId, create_blocked: Blocked ) -> Result<Self>

Same as create_for_contact() with an additional create_blocked parameter that is used in case the chat does not exist or to unblock existing chats. create_blocked won’t block already unblocked chats again.

source

pub(crate) async fn create_multiuser_record( context: &Context, chattype: Chattype, grpid: &str, grpname: &str, create_blocked: Blocked, create_protected: ProtectionStatus, param: Option<String>, timestamp: i64 ) -> Result<Self>

Create a group or mailinglist raw database record with the given parameters. The function does not add SELF nor checks if the record already exists.

source

async fn set_selfavatar_timestamp( self, context: &Context, timestamp: i64 ) -> Result<()>

source

pub(crate) async fn set_blocked( self, context: &Context, new_blocked: Blocked ) -> Result<bool>

Updates chat blocked status.

Returns true if the value was modified.

source

pub async fn block(self, context: &Context) -> Result<()>

Blocks the chat as a result of explicit user action.

source

pub(crate) async fn block_ex(self, context: &Context, sync: Sync) -> Result<()>

source

pub async fn unblock(self, context: &Context) -> Result<()>

Unblocks the chat.

source

pub(crate) async fn unblock_ex( self, context: &Context, sync: Sync ) -> Result<()>

source

pub async fn accept(self, context: &Context) -> Result<()>

Accept the contact request.

Unblocks the chat and scales up origin of contacts.

source

pub(crate) async fn accept_ex(self, context: &Context, sync: Sync) -> Result<()>

source

pub(crate) async fn inner_set_protection( self, context: &Context, protect: ProtectionStatus ) -> Result<bool>

Sets protection without sending a message.

Returns whether the protection status was actually modified.

source

pub(crate) async fn add_protection_msg( self, context: &Context, protect: ProtectionStatus, contact_id: Option<ContactId>, timestamp_sort: i64 ) -> Result<()>

Adds an info message to the chat, telling the user that the protection status changed.

Params:

  • contact_id: In a 1:1 chat, pass the chat partner’s contact id.
  • timestamp_sort is used as the timestamp of the added message and should be the timestamp of the change happening.
source

async fn set_protection_for_timestamp_sort( self, context: &Context, protect: ProtectionStatus, timestamp_sort: i64, contact_id: Option<ContactId> ) -> Result<()>

Sets protection and sends or adds a message.

timestamp_sort is used as the timestamp of the added message and should be the timestamp of the change happening.

source

pub(crate) async fn set_protection( self, context: &Context, protect: ProtectionStatus, timestamp_sent: i64, contact_id: Option<ContactId> ) -> Result<()>

Sets protection and sends or adds a message.

timestamp_sent is the “sent” timestamp of a message caused the protection state change.

source

pub(crate) async fn set_protection_for_contact( context: &Context, contact_id: ContactId, timestamp: i64 ) -> Result<()>

Sets the 1:1 chat with the given address to ProtectionStatus::Protected, and posts a SystemMessage::ChatProtectionEnabled into it.

If necessary, creates a hidden chat for this.

source

pub async fn set_visibility( self, context: &Context, visibility: ChatVisibility ) -> Result<()>

Archives or unarchives a chat.

source

pub(crate) async fn set_visibility_ex( self, context: &Context, sync: Sync, visibility: ChatVisibility ) -> Result<()>

source

pub async fn unarchive_if_not_muted( self, context: &Context, msg_state: MessageState ) -> Result<()>

Unarchives a chat that is archived and not muted. Needed after a message is added to a chat so that the chat gets a normal visibility again. msg_state is the state of the message. Matters only for incoming messages currently. For multiple outgoing messages the function may be called once with MessageState::Undefined. Sending an appropriate event is up to the caller. Also emits DC_EVENT_MSGS_CHANGED for DC_CHAT_ID_ARCHIVED_LINK when the number of archived chats with unread messages increases (which is possible if the chat is muted).

source

pub(crate) fn emit_msg_event( self, context: &Context, msg_id: MsgId, important: bool )

Emits an appropriate event for a message. important is whether a notification should be shown.

source

pub async fn delete(self, context: &Context) -> Result<()>

Deletes a chat.

source

pub async fn set_draft( self, context: &Context, msg: Option<&mut Message> ) -> Result<()>

Sets draft message.

Passing None as message just deletes the draft

source

async fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>>

Returns ID of the draft message, if there is one.

source

pub async fn get_draft(self, context: &Context) -> Result<Option<Message>>

Returns draft message, if there is one.

source

async fn maybe_delete_draft(self, context: &Context) -> Result<bool>

Deletes draft message, if there is one.

Returns true, if message was deleted, false otherwise.

source

async fn do_set_draft( self, context: &Context, msg: &mut Message ) -> Result<bool>

Set provided message as draft message for specified chat. Returns true if the draft was added or updated in place.

source

pub async fn get_msg_cnt(self, context: &Context) -> Result<usize>

Returns number of messages in a chat.

source

pub async fn get_fresh_msg_cnt(self, context: &Context) -> Result<usize>

Returns the number of fresh messages in the chat.

source

pub(crate) async fn get_timestamp( self, context: &Context ) -> Result<Option<i64>>

Returns timestamp of the latest message in the chat.

source

pub async fn get_similar_chat_ids( self, context: &Context ) -> Result<Vec<(ChatId, f64)>>

Returns a list of active similar chat IDs sorted by similarity metric.

Jaccard similarity coefficient is used to estimate similarity of chat member sets.

Chat is considered active if something was posted there within the last 42 days.

source

pub async fn get_similar_chatlist(self, context: &Context) -> Result<Chatlist>

Returns similar chats as a Chatlist.

source

pub(crate) async fn get_param(self, context: &Context) -> Result<Params>

source

pub(crate) async fn is_unpromoted(self, context: &Context) -> Result<bool>

Returns true if the chat is not promoted.

source

pub(crate) async fn is_promoted(self, context: &Context) -> Result<bool>

Returns true if the chat is promoted.

source

pub async fn is_self_talk(self, context: &Context) -> Result<bool>

Returns true if chat is a saved messages chat.

source

pub async fn is_device_talk(self, context: &Context) -> Result<bool>

Returns true if chat is a device chat.

source

async fn parent_query<T, F>( self, context: &Context, fields: &str, state_out_min: MessageState, f: F ) -> Result<Option<T>>
where F: Send + FnOnce(&Row<'_>) -> Result<T>, T: Send + 'static,

source

async fn get_parent_mime_headers( self, context: &Context, state_out_min: MessageState ) -> Result<Option<(String, String, String)>>

source

pub async fn get_encryption_info(self, context: &Context) -> Result<String>

Returns multi-line text summary of encryption preferences of all chat contacts.

This can be used to find out if encryption is not available because keys for some users are missing or simply because the majority of the users in a group prefer plaintext emails.

To get more verbose summary for a contact, including its key fingerprint, use Contact::get_encrinfo.

source

pub fn to_u32(self) -> u32

Bad evil escape hatch.

Avoid using this, eventually types should be cleaned up enough that it is no longer necessary.

source

pub(crate) async fn reset_gossiped_timestamp( self, context: &Context ) -> Result<()>

source

pub async fn get_gossiped_timestamp(self, context: &Context) -> Result<i64>

Get timestamp of the last gossip sent in the chat. Zero return value means that gossip was never sent.

source

pub(crate) async fn set_gossiped_timestamp( self, context: &Context, timestamp: i64 ) -> Result<()>

source

pub async fn is_protected(self, context: &Context) -> Result<ProtectionStatus>

Returns true if the chat is protected.

source

pub(crate) async fn calc_sort_timestamp( self, context: &Context, message_timestamp: i64, always_sort_to_bottom: bool, incoming: bool ) -> Result<i64>

Returns the sort timestamp for a new message in the chat.

message_timestamp should be either the message “sent” timestamp or a timestamp of the corresponding event in case of a system message (usually the current system time). always_sort_to_bottom makes this ajust the returned timestamp up so that the message goes to the chat bottom. incoming – whether the message is incoming.

source§

impl ChatId

source

pub async fn get_ephemeral_timer(self, context: &Context) -> Result<Timer>

Get ephemeral message timer value in seconds.

source

pub(crate) async fn inner_set_ephemeral_timer( self, context: &Context, timer: Timer ) -> Result<()>

Set ephemeral timer value without sending a message.

Used when a message arrives indicating that someone else has changed the timer value for a chat.

source

pub async fn set_ephemeral_timer( self, context: &Context, timer: Timer ) -> Result<()>

Set ephemeral message timer value in seconds.

If timer value is 0, disable ephemeral message timer.

source§

impl ChatId

source

pub(crate) async fn update_timestamp( &self, context: &Context, scope: Param, new_timestamp: i64 ) -> Result<bool>

Updates a chat id’s timestamp on disk, if reasonable. Returns true if the caller shall update the settings belonging to the scope.

Trait Implementations§

source§

impl Clone for ChatId

source§

fn clone(&self) -> ChatId

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ChatId

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ChatId

source§

fn default() -> ChatId

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ChatId

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for ChatId

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromSql for ChatId

Allow converting an SQLite integer directly into ChatId.

source§

fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>

Converts SQLite value into Rust value.
source§

impl Hash for ChatId

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for ChatId

source§

fn cmp(&self, other: &ChatId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for ChatId

source§

fn eq(&self, other: &ChatId) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ChatId

source§

fn partial_cmp(&self, other: &ChatId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for ChatId

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToSql for ChatId

Allow converting ChatId to an SQLite type.

This allows you to directly store ChatId into the database as well as query for a ChatId.

source§

fn to_sql(&self) -> Result<ToSqlOutput<'_>>

Converts Rust value to SQLite value
source§

impl Copy for ChatId

source§

impl Eq for ChatId

source§

impl StructuralEq for ChatId

source§

impl StructuralPartialEq for ChatId

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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

§

impl<T> RpcError for T
where T: Debug + Display + Send + Sync + Unpin + 'static,

§

impl<T> RpcMessage for T
where T: Debug + Serialize + DeserializeOwned + Send + Sync + Unpin + 'static,