Skip to content

api survey

Floris Bruynooghe edited this page Feb 12, 2021 · 4 revisions

API conventions

Rust API conventions in the deltachat-core-rust library.

Survey

A survey of existing APIs used to create the main objects. The APIs as shown are not actual signatures, but only approximations that allow to compare their behaviour without the full complexity.

Questions:

  • Any main types missing?
  • Any constructors missing?

In-Memory Only

ChatId::new(id: u32);
// -> Self
MsgId::new(id: u32);  // Also MsgId::new_unset()
// -> Self
Message::new(viewtype: ViewType);
// -> Self

Read from DB by ID, error if not there

Contact::load_from_db(context: &Context, contact_id: u32);
// -> Result<Self>
Chat::load_from_db(context: &Context, chat_id: ChatId);
// -> Result<Self>
Message::load_from_db(context: &Context, id: MsgId);
// -> Result<Message>

Other

Contact::add_or_lookup(context: &Context, name: &str, addr: &str);
//-> Result<(u32, Modifier)>
Contact::lookup_id_by_addr(context: &Context, addr: &str, min_origin: Origin);
// -> Result<Option<u32>>
Contact::create(context: &Context, name: &str, addr: &str);
// -> Result<u32>
Contact::get_all(context: &Context, listflags: u32, query: &str);
// -> Result<Vec<u32>>
Contact::get_all_blocked(context: &Context);
// -> Vec<u32>

chat::create_by_contact_id(context: &Context, contact_id: u32);
// -> Result<ChatId>
chat::create_by_msg_id(context: &Context, msg_id: MsgId);
// -> Result<ChatId>
chat::create_group_chat(context: &Context, protect: ProtectionStatus, chat_name: &str);
// -> Result<ChatId>
chat::create_or_lookup_by_contact_id(context: &Context, contact_id: u32, create_blocked: Blocked);
//-> Result<(ChatId, Blocked)>
chat::lookup_by_contact_id(context: &Context, contact_id: u32);
// -> Result<(ChatId, Blocked)>

BlobObject::create(context: &Context, suggested_name: &str, data: &[u8]);
// -> Result<Self>
Clone this wiki locally