Skip to main content

scp2p_core/
lib.rs

1// Copyright (c) 2024-2026 Vanyo Vanev / Tech Art Ltd
2// SPDX-License-Identifier: MPL-2.0
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at https://mozilla.org/MPL/2.0/.
7pub mod api;
8pub mod blob_store;
9pub mod capabilities;
10pub mod cbor;
11pub mod config;
12pub mod content;
13pub mod dht;
14pub mod dht_keys;
15pub mod ids;
16pub mod manifest;
17pub mod net_fetch;
18pub mod peer;
19pub mod peer_db;
20pub mod relay;
21pub mod search;
22pub mod store;
23pub mod transfer;
24pub mod transport;
25pub mod transport_net;
26pub mod wire;
27
28pub use api::{
29    AbuseLimits, ActiveRelaySlot, BlocklistRules, CommunityMembershipToken, Node, NodeHandle,
30    OwnedShareRecord, SearchPage, SearchPageQuery, SearchQuery, SearchResult, SearchTrustFilter,
31    ShareItemInfo, SubscriptionTrustLevel,
32};
33pub use capabilities::Capabilities;
34pub use config::NodeConfig;
35pub use content::{
36    CHUNK_SIZE, ChunkedContent, chunk_hashes, compute_chunk_list_hash, describe_content,
37    verify_chunk, verify_chunked_content, verify_content,
38};
39pub use dht::{
40    ALPHA, DEFAULT_TTL_SECS, Dht, DhtInsertResult, DhtNodeRecord, DhtValue, K, MAX_TTL_SECS,
41    MAX_VALUE_SIZE,
42};
43pub use dht_keys::{community_info_key, content_provider_key, manifest_loc_key, share_head_key};
44pub use ids::{ContentId, ManifestId, NodeId, ShareId};
45pub use manifest::{
46    ItemV1, ManifestV1, PublicShareSummary, ShareHead, ShareKeypair, ShareVisibility,
47};
48pub use net_fetch::{
49    BoxedStream, DirectRequestTransport, FetchPolicy, OwnedRelayAwareTransport, PeerConnector,
50    ProgressCallback, RelayAwareTransport, RequestTransport, SessionPoolTransport,
51    download_swarm_over_network, download_swarm_to_file, fetch_manifest_with_retry,
52    send_request_on_stream,
53};
54pub use peer::{PeerAddr, RelayRoute, TransportProtocol};
55pub use peer_db::{
56    CAPABILITY_FRESHNESS_WINDOW_SECS, PEX_FRESHNESS_WINDOW_SECS, PEX_MAX_PEERS, PeerDb, PeerRecord,
57};
58pub use store::{
59    EncryptedSecret, MemoryStore, PersistedCommunity, PersistedPartialDownload,
60    PersistedPublisherIdentity, PersistedState, PersistedSubscription, SqliteStore, Store,
61    decrypt_secret, encrypt_secret,
62};
63
64pub use transfer::{ChunkProvider, download_swarm};
65
66pub use relay::{
67    BandwidthClass, RELAY_ANNOUNCEMENT_MAX_TTL_SECS, RELAY_RENDEZVOUS_BUCKET_SECS,
68    RELAY_RENDEZVOUS_N, RELAY_SLOT_TTL_SECS, RelayAnnouncement, RelayCapacity, RelayLimits,
69    RelayLink, RelayManager, RelayPayloadKind as RelayInternalPayloadKind, RelayScore, RelaySlot,
70    RelayStream as RelayInternalStream, RelayTunnelRegistry,
71};
72/// Application version string, derived from `Cargo.toml`.
73///
74/// This is the single source of truth for version display and update
75/// checks.  The workspace `[workspace.package].version` value flows
76/// through here so all crates share the same version.
77pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
78
79pub use transport::{
80    AuthenticatedSession, DispatchResult, HANDSHAKE_MAX_BYTES, NonceTracker, NoopDispatcher,
81    WireDispatcher, dispatch_envelope, generate_nonce, handshake_initiator, handshake_responder,
82    read_envelope, run_message_loop, write_envelope,
83};
84pub use transport_net::{
85    QuicBiStream, QuicClientSession, QuicServerHandle, TlsServerHandle, build_tls_server_handle,
86    quic_accept_bi_session, quic_connect_bi_session, quic_connect_bi_session_insecure,
87    start_quic_server, tls_accept_session, tls_connect_session, tls_connect_session_insecure,
88};
89
90#[cfg(test)]
91mod conformance;