asimov_social/lib.rs
1// This is free and unencumbered software released into the public domain.
2
3//! Social graph primitives for ASIMOV.
4//!
5//! Use [`SocialHandle`] to associate an account handle with its platform,
6//! [`SocialProperty`] to select account information, and [`FollowRelationship`]
7//! to describe the direction of a follow relationship between accounts.
8//! [`SocialLink`] recognizes URLs for profiles, relationships, and other social
9//! resources, with fallible conversions to and from supported account handles.
10//! [`SocialPlatform::handle`] parses an identifier on a selected platform.
11//! URL parsers accept HTTP(S), an optional `www.` hostname prefix, and known host
12//! aliases; formatted URLs use HTTPS without `www.`.
13//!
14//! Platform modules re-export their platform-specific handle types. Each module
15//! and its corresponding `SocialHandle` variant require the matching platform
16//! feature; all platform features are enabled by default.
17//!
18//! [`FetchRequest`] and [`ListRequest`] share asimov-remote's transport-independent
19//! request types and options. The `serde` feature enables their JSON encoding
20//! without an HTTP client; `client` enables `SocialClient` for HTTP execution.
21//! Caching, filtering, and timing are configured on the requests and encoded
22//! alongside pattern options in the JSON `options` object.
23//!
24//! ```
25//! # #[cfg(feature = "serde")] {
26//! use asimov_social::{FetchRequest, ListRequest};
27//!
28//! let fetch = FetchRequest::new("https://example.com/profile", Default::default());
29//! let json = serde_json::to_string(&fetch).unwrap();
30//! assert_eq!(serde_json::from_str::<FetchRequest>(&json).unwrap(), fetch);
31//!
32//! let list: ListRequest = serde_json::from_str(
33//! r#"{"url":"https://example.com/collection","options":{"limit":0}}"#,
34//! ).unwrap();
35//! assert_eq!(list.options.limit, Some(0));
36//! # }
37//! ```
38
39#![no_std]
40#![forbid(unsafe_code)]
41#![allow(unused_imports)]
42#![cfg_attr(docsrs, feature(doc_cfg))]
43
44extern crate alloc;
45
46#[cfg(feature = "std")]
47extern crate std;
48
49pub use asimov_remote::{CachingOptions, FilteringOptions, TimingOptions};
50
51mod collection_stub;
52pub use collection_stub::*;
53
54mod fetch_request;
55pub use fetch_request::*;
56
57mod follow_relationship;
58pub use follow_relationship::*;
59
60mod platform_handles;
61pub use platform_handles::*;
62
63#[cfg(test)]
64mod platform_tests;
65
66mod list_request;
67pub use list_request::*;
68
69#[cfg(feature = "client")]
70mod social_client;
71#[cfg(feature = "client")]
72pub use social_client::*;
73
74mod social_handle;
75pub use social_handle::*;
76
77mod social_link;
78pub use social_link::*;
79
80mod social_platform;
81pub use social_platform::*;
82
83mod social_property;
84pub use social_property::*;
85
86mod social_url;
87
88#[cfg(feature = "facebook")]
89/// Facebook-specific types, including account handles.
90pub mod facebook;
91
92#[cfg(feature = "github")]
93/// GitHub-specific types, including account handles.
94pub mod github;
95
96#[cfg(feature = "gravatar")]
97/// Gravatar-specific types, including account handles.
98pub mod gravatar;
99
100#[cfg(feature = "instagram")]
101/// Instagram-specific types, including account handles.
102pub mod instagram;
103
104#[cfg(feature = "introco")]
105/// Intro.co-specific types, including account handles.
106pub mod introco;
107
108#[cfg(feature = "linkedin")]
109/// LinkedIn-specific types, including account handles.
110pub mod linkedin;
111
112#[cfg(feature = "localai")]
113/// Local.ai-specific types, including account handles.
114pub mod localai;
115
116#[cfg(feature = "luma")]
117/// Luma-specific types, including account handles.
118pub mod luma;
119
120#[cfg(feature = "telegram")]
121/// Telegram-specific types, including account handles.
122pub mod telegram;
123
124#[cfg(feature = "whatsapp")]
125/// WhatsApp-specific types, including account handles.
126pub mod whatsapp;
127
128#[cfg(feature = "x")]
129/// X-specific account handles, profiles, and list identifiers.
130pub mod x;