about summary refs log tree commit diff
path: root/util/src/lib.rs
blob: c840e596f1d41b17ff837587f8819afbfa8da96b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#![warn(missing_docs)]
//! Small things that couldn't fit elsewhere in Kittybox, yet may be
//! useful on their own or in multiple Kittybox crates.
//!
//! Some things are gated behind features, namely:
//!  - `fs` - enables use of filesystem-related utilities
use serde::{Deserialize, Serialize};

#[derive(Clone, Serialize, Deserialize)]
pub struct IndiewebEndpoints {
    pub authorization_endpoint: String,
    pub token_endpoint: String,
    pub webmention: Option<String>,
    pub microsub: Option<String>,
}

/// Data structure representing a Micropub channel in the ?q=channels output.
#[derive(Serialize, Deserialize, PartialEq, Debug)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct MicropubChannel {
    /// The channel's UID. It is usually also a publically accessible permalink URL.
    pub uid: String,
    /// The channel's user-friendly name used to recognize it in lists.
    pub name: String,
}

#[derive(Debug, Default)]
/// Common types of webmentions.
pub enum MentionType {
    /// Corresponds to a `u-in-reply-to` link.
    Reply,
    /// Corresponds to a `u-like-of` link.
    Like,
    /// Corresponds to a `u-repost-of` link.
    Repost,
    /// Corresponds to a `u-bookmark-of` link.
    Bookmark,
    /// A plain link without MF2 annotations.
    #[default]
    Mention
}

/// Common errors from the IndieWeb protocols that can be reused between modules.
pub mod error;
pub use error::{ErrorType, MicropubError};

/// Common data-types useful in creating smart authentication systems.
pub mod auth {
    #[derive(PartialEq, Eq, Hash, Clone, Copy)]
    pub enum EnrolledCredential {
        /// An indicator that a password is enrolled. Passwords can be
        /// used to recover from a lost token.
        Password,
        /// An indicator that one or more WebAuthn credentials were
        /// enrolled.
        WebAuthn
    }
}

/// A collection of traits for implementing a robust job queue.
pub mod queue;

#[cfg(feature = "fs")]
/// Commonly-used operations with the file system in Kittybox's
/// underlying storage mechanisms.
pub mod fs;