Skip to main content

Crate vector_core

Crate vector_core 

Source
Expand description

Vector Core — the single source of truth for all Vector clients, SDKs, and interfaces.

This crate contains ALL of Vector’s business logic, fully decoupled from Tauri. It can be used by:

  • src-tauri: The Tauri desktop/mobile app (thin command shell)
  • vector-cli: Command-line interface
  • Vector SDK: Bot and client libraries
  • Any future interface (web, embedded, etc.)

§Architecture

┌─────────────────────────────────────────────┐
│              vector-core                     │
│                                              │
│  types ─ compact ─ state ─ db ─ crypto       │
│  chat ─ profile ─ net ─ hex                  │
│                                              │
│  traits::EventEmitter (UI abstraction)       │
│  VectorCore (high-level API)                 │
└─────────────────────────────────────────────┘
       ▲              ▲              ▲
  src-tauri       vector-cli     Vector SDK
(AppHandle)      (terminal)     (callbacks)

Re-exports§

pub use types::Message;
pub use types::Attachment;
pub use types::Reaction;
pub use types::EditEntry;
pub use types::ImageMetadata;
pub use types::SiteMetadata;
pub use types::LoginResult;
pub use types::AttachmentFile;
pub use types::mention;
pub use types::extract_mentions;
pub use profile::Profile;
pub use profile::ProfileFlags;
pub use profile::SlimProfile;
pub use profile::Status;
pub use chat::Chat;
pub use chat::ChatType;
pub use chat::ChatMetadata;
pub use chat::SerializableChat;
pub use compact::CompactMessage;
pub use compact::CompactMessageVec;
pub use compact::NpubInterner;
pub use state::ChatState;
pub use state::NOSTR_CLIENT;
pub use state::MY_SECRET_KEY;
pub use state::MY_PUBLIC_KEY;
pub use state::STATE;
pub use state::ENCRYPTION_KEY;
pub use state::nostr_client;
pub use state::my_public_key;
pub use state::has_active_session;
pub use state::set_nostr_client;
pub use state::set_my_public_key;
pub use state::take_nostr_client;
pub use state::clear_my_public_key;
pub use state::set_pending_bunker_setup;
pub use state::pending_bunker_setup;
pub use state::clear_pending_bunker_setup;
pub use crypto::GuardedKey;
pub use crypto::GuardedSigner;
pub use signer::SignerKind;
pub use signer::signer_kind;
pub use signer::set_signer_kind;
pub use signer::is_bunker;
pub use signer::BUNKER_SIGNER;
pub use signer::bunker_signer;
pub use signer::set_bunker_signer;
pub use signer::take_bunker_signer;
pub use signer::build_bunker_signer;
pub use signer::prewarm_bunker;
pub use signer::drain_bunker_state;
pub use signer::parse_bunker_remote_pubkey;
pub use signer::parse_bunker_relays;
pub use signer::BunkerConnectionState;
pub use signer::bunker_state;
pub use signer::set_bunker_state;
pub use signer::VectorAuthUrlHandler;
pub use signer::attempt_bunker_login;
pub use signer::WatchedBunkerSigner;
pub use signer::vector_metadata;
pub use signer::build_nostrconnect_uri;
pub use signer::build_nostrconnect_session;
pub use signer::VECTOR_APP_NAME;
pub use signer::VECTOR_APP_URL;
pub use signer::VECTOR_APP_ICON;
pub use error::VectorError;
pub use error::Result;
pub use traits::EventEmitter;
pub use traits::NoOpEmitter;
pub use traits::set_event_emitter;
pub use traits::emit_event;
pub use db::set_app_data_dir;
pub use db::get_app_data_dir;
pub use sending::SendCallback;
pub use sending::NoOpSendCallback;
pub use sending::SendConfig;
pub use sending::SendResult;
pub use deletion::delete_own_dm;
pub use deletion::DeleteOutcome;
pub use stored_event::StoredEvent;
pub use stored_event::StoredEventBuilder;
pub use stored_event::SystemEventType;
pub use rumor::RumorEvent;
pub use rumor::RumorContext;
pub use rumor::ConversationType;
pub use rumor::RumorProcessingResult;
pub use rumor::process_rumor;
pub use profile::SyncPriority;
pub use profile::ProfileSyncHandler;
pub use profile::NoOpProfileSyncHandler;
pub use event_handler::InboundEventHandler;
pub use event_handler::NoOpEventHandler;
pub use event_handler::PreparedEvent;
pub use event_handler::process_event;

Modules§

badges
Profile badges — fetch, validate, and cache.
blossom
blossom_capabilities
Per-(server, mime, encrypted) Blossom capability cache and routing.
blossom_servers
BUD-03 user blossom server list (kind 10063) — store, merge, publish, fetch.
bot_interface
Bot Interface — manifests + slash commands (Phase 1 of the bot-UI layer).
chat
Chat types and management — compact message storage.
community
Vector Community protocol (GROUP_PROTOCOL.md).
compact
Compact message storage with binary IDs and interned strings.
crypto
db
Database layer — SQLite with per-account databases.
deletion
Message deletion — Vector’s “delete from network” capability.
emoji_packs
NIP-30 / NIP-51 custom emoji + pack support.
emoji_usage
Per-account emoji “frecency” (most-used) tracker — SQL-backed.
error
Error types for vector-core.
event_handler
Event handler — gift wrap receive, unwrap, process, commit pipeline.
inbox_relays
NIP-17 Kind 10050 (DM Relay List) support.
negentropy
Shared NIP-77 negentropy set reconciliation.
net
Network utilities — SSRF protection, HTTP client helpers.
profile
Profile types and sync — compact internal representation + relay fetching.
rumor
Rumor Processing Module
self_destruct
Self-Destruct Timer — per-chat NIP-40 message expiry (“disappearing messages”). The per-chat lifespan is a DURATION stored in the account settings KV; each outgoing DM in that chat is stamped with an absolute NIP-40 expiry so relays drop the gift-wrap and every compliant client purges its local copy on schedule. Purge is local-only per client — the expiry tag travels with the message, so no delete broadcast is needed.
sending
Message sending — NIP-17 gift-wrapped DMs (text and file attachments).
signer
Polymorphic signer — local key vault vs. NIP-46 remote bunker.
simd
SIMD-accelerated operations.
state
Global state management — ChatState, globals, processing gate.
stats
Cache statistics and memory measurement for benchmarking.
stored_event
Flat Event Storage Module
traits
Abstraction traits that decouple vector-core from any specific UI framework.
types
Core type definitions for Vector.
wallpaper
Per-DM wallpaper feature.
webxdc
WebXDC Mini App helpers shared across transports (DM + Community).

Macros§

log_debug
log_info
Log macros shared across all Vector clients.
log_trace
log_warn

Structs§

CoreConfig
Configuration for initializing VectorCore.
VectorCore
The main entry point for Vector Core.

Functions§

community_relay_options
Relay options for a Community / “external” relay: the GOSSIP flag (+ PING for a 24/7 keepalive connection). GOSSIP is read/write-capable when TARGETED — can_read() is READ|GOSSIP|DISCOVERY and can_write() is WRITE|GOSSIP, so per-relay checks pass for fetch_events_from / send_event_to / subscribe_to. But pool-wide ops select READ-only / WRITE-only relays, so the DM/giftwrap subscription (subscribe(None)) and the user’s outbox (send_event) skip GOSSIP relays — the user’s own traffic never touches relays they don’t own. (A bare PING-only relay can NOT be used: can_write()/can_read() are false → the relay layer returns WriteDisabled / ReadDisabled.) An overlap relay that’s ALSO a user relay keeps its existing READ+WRITE flags — add_relay is a no-op (Ok(false)) for a url already pooled, reusing the one existing connection.
discovery_relay_options
Relay options for a Discovery Relay (see state::DISCOVERY_RELAYS): the same GOSSIP|PING targeted-only isolation as Community relays — reachable via fetch_events_from / send_event_to, invisible to pool-wide DM/profile ops. An overlap with a user relay keeps the user’s READ+WRITE flags (add_relay no-ops on an already-pooled url).
nostr_client_options
Build a nostr_sdk::ClientOptions with the embedded-Tor SOCKS proxy applied if (and only if) the tor feature is on AND tor::TorService is currently active. When Tor is off, returns the default options unchanged.
tor_aware_relay_options
Augment a RelayOptions with the Tor connection mode when active. Used by every site that adds a relay to the pool — default relays at boot, custom user relays, community relays, NIP-17 inbox relays — so they all come up through Tor when the toggle is on.