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 state::set_pending_nip55_setup;
pub use state::pending_nip55_setup;
pub use state::clear_pending_nip55_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::is_keyless;
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 nip55::Nip55Backend;
pub use nip55::Nip55Error;
pub use nip55::Nip55ResolverOutcome;
pub use nip55::Nip55Signer;
pub use nip55::Nip55State;
pub use nip55::set_nip55_backend;
pub use nip55::nip55_backend;
pub use nip55::nip55_state;
pub use nip55::set_nip55_state;
pub use nip55::drain_nip55_state;
pub use nip55::nip55_is_installed;
pub use nip55::nip55_pair;
pub use nip55::nip55_perms_json;
pub use nip55::VECTOR_NIP55_SIGN_KINDS;
pub use nip55::VECTOR_NIP55_ENCRYPT_TYPES;
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_ext
Event-builder helpers.
event_handler
Event handler — gift wrap receive, unwrap, process, commit pipeline.
inbox_relays
NIP-17 Kind 10050 (DM Relay List) support.
logging
Runtime log-level gate for the log_* macros.
negentropy
Shared NIP-77 negentropy set reconciliation.
net
Network utilities — SSRF protection, HTTP client helpers.
nip55
NIP-55 “offline” signer — an on-device signer app (Amber) reached over local Android IPC instead of a relay.
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
tags
Kind-based tag lookups.
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_net_fail
Network-failure log: a WARN that ALSO lands in the app’s persistent log (Settings > Copy Logs) via the registered sink — for upload/download/ mirror failures the user may need to report long after the console scrolled away. No toast: fallbacks often succeed right after.
log_net_info
Network-milestone log: persisted like log_net_fail! but INFO-toned — which server won an upload, which fallback served a download, mirror results. Persisted even in release (where log_info! compiles out): the persistent log exists precisely for release-build diagnosis.
log_trace
log_warn

Structs§

CoreConfig
Configuration for initializing VectorCore.
VectorAuthenticator
NIP-42 authenticator.
VectorCore
The main entry point for Vector Core.

Traits§

ClientRelayExt
Register a relay with the pool’s own auto-reconnect disabled.

Functions§

apply_tor_proxy
Apply the Tor proxy policy to any ClientBuilder.
community_relay_capabilities
Capabilities for a Community / “external” relay: GOSSIP only.
discovery_relay_capabilities
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_builder
A ClientBuilder carrying Vector’s client-wide policy: NIP-42 auth plus the embedded-Tor SOCKS proxy.
relay_connect_timeout
Adjust a relay connect budget for the transport actually in use.
relay_request_timeout
Adjust a relay request budget for the transport actually in use.
resubscribe_relay_after_reconnect
Re-send every live subscription this relay is supposed to carry, after VECTOR reconnected it.
send_gift_wrap
Seal, wrap and publish a rumor to receiver.
sign_and_send
Sign an EventBuilder with the session signer and publish it.
sign_builder
Sign an EventBuilder with the session signer.