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 is used by:
- src-tauri: the desktop and mobile app (a thin command shell)
- Vector Web: the same frontend in a browser, over this crate compiled to wasm32
- vector_sdk: bots and clients, with vector-media for voice without devices
- vector-cli, concord-cli and the vector-agent MCP server
§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 transport::ws::apply_transport;pub use transport::ws::transport_relay_options;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::MY_SECRET_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 nip07::Nip07Backend;pub use nip07::Nip07Signer;pub use nip07::set_nip07_backend;pub use nip07::nip07_backend;pub use nip07::nip07_get_public_key;pub use error::DownloadError;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::delete_received_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::LiveOnly;pub use event_handler::NoOpEventHandler;pub use event_handler::PreparedEvent;pub use event_handler::Presence;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_
error - What a Blossom server said when it refused — as data, not prose.
- blossom_
info - The server information document (
GET /.well-known/blossom). - blossom_
servers - BUD-03 user blossom server list (kind 10063) — store, merge, publish, fetch.
- blossom_
stats - Per-server latency, speed and reachability, and the one-word status the list shows.
- boot_
payload - The
init_finishedpayload with every field left out that matches its template. - bot_
interface - Bot Interface — manifests + slash commands (Phase 1 of the bot-UI layer).
- calls
- Calls: the platform-free half from
vector-calls, and withcallsthe session itself. Calls. The platform-free half (wire format, jitter buffer, rate control) is thevector-callscrate, re-exported here; with thecallsfeature, the session and its video track run here too, over whatever a client plugs intoplatform. - chat
- Chat types and management — compact message storage.
- clock
- The time Vector stamps and judges by: this device’s clock, corrected when the account’s
relays agree it is off. Every HTTPS answer carries a
Date(RFC 9110 §6.6.1), so any relay can tell the time, whether or not it serves NIP-11; their median moves the clock, so one wrong relay can’t, and nothing of Vector’s own is asked. - community
- Vector Communities, on the Concord v2 (CORD) protocol in
v2, plus the pieces every layer shares: ids, epochs, images, transport, roles and moderation. - compact
- Compact message storage with binary IDs and interned strings.
- crypto
- db
- Database layer — SQLite with per-account databases.
- deep_
link - Deep links: the places a link opens in Vector, in the one grammar every client parses.
- deletion
- Message deletion: Vector’s “delete from network” for DMs.
- dm_
catchup - DM catch-up: what our read relays hold for us that we don’t, fetched once each.
- early
- A message dated ahead of this device’s (corrected) clock waits until its time instead of showing at once: shown early, it would sit below everything sent after it, holding the bottom of the chat. Held in memory and never marked handled, so one cut short by a restart comes back through the next sync or history read, and released through the normal path, which judges it afresh, notifies and counts it unread as if it arrived then.
- 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.
- event_
json - Events read from JSON: nostr-parse first, rust-nostr’s reader for anything it refuses.
- event_
size - The relay size ceiling: every event Vector publishes, its outer wrap included, serializes to at most 65,536 bytes (CORD-02 Appendix B), since a relay refuses a larger one whole.
- events_
tracker - Seen-event tracker for short-lived relay clients. nostr-sdk’s default allocates its whole 35k-entry table up front for every client; this one keeps the same bound but grows with what the client actually sees, so a client that fetches a page and goes holds a page.
- fasthash
- Hash maps for keys a peer can choose (edition and event ids, npubs) that live within one computation, as a fold’s do: foldhash’s speed, seeded with a secret from the OS. foldhash seeds itself from addresses and the clock, which a wasm build leaves fixed, so a precomputed set of colliding ids would slow every reader.
- files
- Files an account keeps beside its database, on either target: the filesystem natively, OPFS on the web. Async because OPFS only answers through promises; natively the calls are the same std::fs ones as before.
- golink
- Vector links: a community, a channel or a message, named by the ids its members already hold.
- history_
gaps - Holes in a channel’s held history.
- i2p
- I2P as a transport kind, over a router the user already runs (i2pd, Java I2P, i2pd-android) through its SAMv3 bridge.
- image_
crop - A crop the user drew, mapped onto the image it is for.
- image_
prep - Images made ready to share: decoded, turned upright, fitted to a size and a byte budget, and
re-encoded. Re-encoding drops every byte of metadata the original carried, camera EXIF and
GPS included. Animated GIF and WebP keep their animation: they pass through when they
already fit, keeping only the blocks that draw them. An animated PNG is shared as its first
frame.
stripdoes the same without re-encoding, for an image too large to. - inbox_
relays - NIP-17 Kind 10050 (DM Relay List) support.
- live_
subs - Live subscriptions that outlast a relay closing them, and catch-ups for the gaps they leave.
- logging
- Runtime log-level gate for the
log_*macros. - media
- Media Vector shows without writing it down: decrypted bytes held in memory per account
(
ram), read through one interface whatever holds them. - negentropy
- Shared NIP-77 negentropy set reconciliation.
- net
- Network utilities — SSRF protection, HTTP client helpers.
- news
- What a listening client is told as news: everything sent since it began listening, once, however it reached this device (live, a catch-up, a replay). What came before is history: stored, never announced.
- nip07
- NIP-07 browser signer — a
window.nostrextension (Alby, nos2x, …) in the page hosting a web build. - nip55
- NIP-55 “offline” signer — an on-device signer app (Amber) reached over local Android IPC instead of a relay.
- nostr_
embed - Nostr content referenced from a chat message (a post, an article, a video), fetched from relays and shaped for an inline card.
- notify
- Notification levels and mutes, for communities, channels and DMs alike.
- pinned_
chats - Pinned Chats — the account’s favourite conversations, synced across its own devices.
- profile
- Profile types and sync — compact internal representation + relay fetching.
- proxy
- Pictures, files and previews fetched by the user’s Magnitude server instead of by this device.
- push
- Sealed push, Vector’s half of it: the tickets this device hands its contacts, the tickets
contacts hand us, and the notification a delivered DM sends to the recipient’s devices.
The protocol is the
vector-pushcrate. - rail_
layout - The community rail’s arrangement: an ordered list of communities and the folders that group them, synced across the account’s own devices.
- relay_
info - What Vector shows of a relay: its NIP-11 name and icon, and whether it asks clients to AUTH.
- requests
- DM requests: a GUI shields its user from someone who wrote first until they answer or accept. Off unless a GUI turns it on, so SDK clients and bots take every DM and invite as they always have.
- rt
- Task and timer facade: tokio natively, the browser event loop on wasm32.
- rumor
- Rumor Processing Module
- secrets
- Secrets a message should never carry: a Nostr private key, a wallet’s seed phrase or a wallet private key. Clients ask before sending one; only a checksum that verifies counts, so ordinary words and ids never trip it.
- 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, NIP-46 remote bunker, or an external signer (NIP-55 app, NIP-07 browser extension).
- simd
- SIMD-accelerated operations.
- spawn_
audit - The “every task carries its account” check, run by this crate’s suite and
by every crate that spawns per-account work against vector-core.
The policy check behind
crate::db::spawn_bound, shared by every crate that spawns per-account work. - start_
menu - The widescreen Main Menu’s pins: what a user keeps one click away, in the
rail’s shape (
RailLayout) and synced the same way, as its own document (vector/start,crate::synced_prefs::Pref::Start). - state
- Global state management — ChatState, globals, processing gate.
- stats
- Cache statistics and memory measurement for benchmarking.
- stored_
event - Flat Event Storage Module
- svg
- Untrusted SVG, rendered to pixels in Rust: no SVG markup reaches a webview from here.
- synced_
prefs - Account preferences that follow you between your own devices: the block list, the mute list, nicknames, and the general settings document.
- tags
- Kind-based tag lookups.
- text_
color - Coloured text outside code blocks.
- text_
spans - Inline annotations a sender writes as markup and the wire carries as tags: colour
(
text_color) and times (text_time). Core takes the markup out at every send and edit; each span names a char range of the plain content that other clients read. - text_
time - Times that read the same everywhere, Discord’s
<t:UNIX:STYLE>. - tls
- TLS for the relay sockets Vector opens itself: ring, the webpki roots, a verifier that remembers each certificate chain it has verified, and session resumption.
- traits
- Abstraction traits that decouple vector-core from any specific UI framework.
- transfer
- Device transfer: move an account to another device by scanning a QR or typing a short code. Both devices meet on relays, prove the code to each other with a PAKE, and the key moves only after the user approves on the device that holds it.
- transport
- The transport meta-glue: one egress decision for every TCP connection Vector opens, and one process bridge that any anonymity network plugs into.
- types
- Core type definitions for Vector.
- vcache
- Vector Cache: the pictures and media Vector keeps for itself (avatars, banners, emoji, icons, previews), sealed on disk under a per-install key so nothing in the app’s folders is a plain image to a gallery, an indexer or another app.
- video_
poster - A web video’s opening, enough for a webview to show its first frame, fetched as byte ranges rather than the whole file.
- wallpaper
- Per-DM wallpaper feature.
- webxdc
- WebXDC Mini App helpers shared across transports (DM + Community).
- webxdc_
permissions - Mini App Permissions System
- xdc
- Mini App (WebXDC) realtime sessions for headless clients: a bot can join the game a player shared, speak its protocol, and leave.
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 (wherelog_info!compiles out): the persistent log exists precisely for release-build diagnosis. - log_
trace - log_
warn
Structs§
- Backfill
Count - What one catch-up page cost and what it yielded.
- Core
Config - Configuration for initializing VectorCore.
- Link
Preview - What a public invite link shows before joining.
- NewChannel
- How a new Channel starts. The default is a public chat Channel at the top level.
- NewCommunity
- How a new Community starts. The default is one
#generalChannel on the active relays. - Post
Options - How a post goes out. The default is a plain post, with pictures compressed.
- Vector
Authenticator - NIP-42 authenticator.
- Vector
Core - The main entry point for Vector Core.
Enums§
- CatchUp
- Who fetches what was published while a
listenclient was offline. - Download
Step - What
VectorCore::download_attachment_reportingis doing, as it happens.
Traits§
- Client
Relay Ext - Register a relay with the pool’s own auto-reconnect disabled.
Functions§
- apply_
tor_ proxy Deprecated - The transport for any
ClientBuilder, as the user’s own lane. - 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 viafetch_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_relayno-ops on an already-pooled url). - fetch_
answered - Read
filterfrom the user’s read relays, orErrunless at least one relay reached EOSE. - newest_
replaceable - The newest of a replaceable event’s copies: highest
created_at, then lowest id, as relays keep. - nostr_
client_ builder - A
ClientBuildercarrying Vector’s client-wide policy: NIP-42 auth plus the transport. - relay_
connect_ timeout - A relay connect budget for the transport in use: the caller’s clearnet value, raised to the chosen kind’s floor.
- relay_
request_ timeout - A relay round-trip budget for the transport in use. A relay that answers a probe in 200ms direct can take many seconds through three hops.
- 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
EventBuilderwith the session signer and publish it. - sign_
builder - Sign an
EventBuilderwith the session signer, refusing an event no relay would store. - tor_
relay_ options Deprecated - Relay options carrying the transport, for clients the SDK builds itself (NIP-46).
- transport_
aware - A publish waiting on the transport’s budget for its OK and NIP-42 challenge: the SDK’s fixed 10 s marks a Tor-slow publish failed while the relay is still answering.