libqaul_types/contacts.rs
1//! Per-user contact book management
2//!
3//! When querying user information from libqaul, a profile contains a
4//! lot of publicly available information, which is (or should be) the
5//! same for all users on the network. To allow applications to tag
6//! users with additional information, the contact API provides an
7//! overlay type that achieves this.
8
9use serde::{Deserialize, Serialize};
10
11/// Per-user local contact access on the network
12///
13/// All fields in this structure are entirely optional and can not be
14/// relied on. They are additional points of data, that a user can
15/// specify about another user, that are not available or shared with
16/// the network. This is meant to allow users to curate a list of
17/// trusted contacts, or build friend circles.
18#[derive(Serialize, Deserialize, Default, Debug, Clone)]
19pub struct ContactEntry {
20 /// The name by which the associated contact is known by the owning user.
21 pub nick: Option<String>,
22 /// Set a user trust level
23 pub trust: i8,
24 /// The user has met this person
25 pub met: bool,
26 /// A free text location
27 pub location: Option<String>,
28 /// A general plain text notes section
29 pub notes: Option<String>,
30}
31
32/// Query structure to find contacts by
33///
34/// A query is always applied to a field that is present in
35/// `ContactEntry`, and will filter contacts by what set of
36/// prerequisites they fulfill.
37#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
38pub enum ContactQuery {
39 /// A fuzzy nickname search
40 Nick(String),
41 /// A fuzzy trust level search
42 Trust { val: i8, fuz: i8 },
43 /// Filter by physical meeting
44 Met(bool),
45 /// A fuzzy location string search
46 Location(String),
47 /// A fuzzy notes string search
48 Notes(String),
49}