Skip to content

Commit

Permalink
refactor: [torrust#1137] rename lib to torrust_tracker_lib
Browse files Browse the repository at this point in the history
to avoid collisions in docs:

```
cargo doc --no-deps --bins --examples --workspace --all-features
```

becuase the main binary and lib have the same name.
  • Loading branch information
josecelano committed Dec 27, 2024
1 parent 4291bba commit bfaf08b
Show file tree
Hide file tree
Showing 30 changed files with 70 additions and 67 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ repository.workspace = true
rust-version.workspace = true
version.workspace = true

[lib]
name = "torrust_tracker_lib"

[workspace.package]
authors = ["Nautilus Cyberneering <[email protected]>, Mick van Dijke <[email protected]>"]
categories = ["network-programming", "web-programming"]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/e2e_tests_runner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Program to run E2E tests.
use torrust_tracker::console::ci::e2e;
use torrust_tracker_lib::console::ci::e2e;

fn main() -> anyhow::Result<()> {
e2e::runner::run()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/profiling.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This binary is used for profiling with [valgrind](https://valgrind.org/)
//! and [kcachegrind](https://kcachegrind.github.io/).
use torrust_tracker::console::profiling::run;
use torrust_tracker_lib::console::profiling::run;

#[tokio::main]
async fn main() {
Expand Down
6 changes: 3 additions & 3 deletions src/core/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! Keys are stored in this struct:
//!
//! ```rust,no_run
//! use torrust_tracker::core::auth::Key;
//! use torrust_tracker_lib::core::auth::Key;
//! use torrust_tracker_primitives::DurationSinceUnixEpoch;
//!
//! pub struct ExpiringKey {
Expand All @@ -26,7 +26,7 @@
//! You can generate a new key valid for `9999` seconds and `0` nanoseconds from the current time with the following:
//!
//! ```rust,no_run
//! use torrust_tracker::core::auth;
//! use torrust_tracker_lib::core::auth;
//! use std::time::Duration;
//!
//! let expiring_key = auth::generate_key(Some(Duration::new(9999, 0)));
Expand Down Expand Up @@ -197,7 +197,7 @@ impl Key {
/// Error returned when a key cannot be parsed from a string.
///
/// ```text
/// use torrust_tracker::core::auth::Key;
/// use torrust_tracker_lib::core::auth::Key;
/// use std::str::FromStr;
///
/// let key_string = "YZSl4lMZupRuOpSRC3krIKR5BPB14nrJ";
Expand Down
8 changes: 4 additions & 4 deletions src/core/databases/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub enum Driver {
/// Example for `SQLite3`:
///
/// ```text
/// use torrust_tracker::core::databases;
/// use torrust_tracker::core::databases::driver::Driver;
/// use torrust_tracker_lib::core::databases;
/// use torrust_tracker_lib::core::databases::driver::Driver;
///
/// let db_driver = Driver::Sqlite3;
/// let db_path = "./storage/tracker/lib/database/sqlite3.db".to_string();
Expand All @@ -41,8 +41,8 @@ pub enum Driver {
/// Example for `MySQL`:
///
/// ```text
/// use torrust_tracker::core::databases;
/// use torrust_tracker::core::databases::driver::Driver;
/// use torrust_tracker_lib::core::databases;
/// use torrust_tracker_lib::core::databases::driver::Driver;
///
/// let db_driver = Driver::MySQL;
/// let db_path = "mysql://db_user:db_user_secret_password@mysql:3306/torrust_tracker".to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use torrust_tracker::{app, bootstrap};
use torrust_tracker_lib::{app, bootstrap};

#[tokio::main]
async fn main() {
Expand Down
8 changes: 4 additions & 4 deletions src/servers/http/v1/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Query {
/// input `name` exists. For example:
///
/// ```text
/// use torrust_tracker::servers::http::v1::query::Query;
/// use torrust_tracker_lib::servers::http::v1::query::Query;
///
/// let raw_query = "param1=value1&param2=value2";
///
Expand All @@ -44,7 +44,7 @@ impl Query {
/// It returns only the first param value even if it has multiple values:
///
/// ```text
/// use torrust_tracker::servers::http::v1::query::Query;
/// use torrust_tracker_lib::servers::http::v1::query::Query;
///
/// let raw_query = "param1=value1&param1=value2";
///
Expand All @@ -60,7 +60,7 @@ impl Query {
/// Returns all the param values as a vector.
///
/// ```text
/// use torrust_tracker::servers::http::v1::query::Query;
/// use torrust_tracker_lib::servers::http::v1::query::Query;
///
/// let query = "param1=value1&param1=value2".parse::<Query>().unwrap();
///
Expand All @@ -73,7 +73,7 @@ impl Query {
/// Returns all the param values as a vector even if it has only one value.
///
/// ```text
/// use torrust_tracker::servers::http::v1::query::Query;
/// use torrust_tracker_lib::servers::http::v1::query::Query;
///
/// let query = "param1=value1".parse::<Query>().unwrap();
///
Expand Down
2 changes: 1 addition & 1 deletion src/servers/http/v1/requests/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const NUMWANT: &str = "numwant";
///
/// ```text
/// use aquatic_udp_protocol::{NumberOfBytes, PeerId};
/// use torrust_tracker::servers::http::v1::requests::announce::{Announce, Compact, Event};
/// use torrust_tracker_lib::servers::http::v1::requests::announce::{Announce, Compact, Event};
/// use bittorrent_primitives::info_hash::InfoHash;
///
/// let request = Announce {
Expand Down
4 changes: 2 additions & 2 deletions src/servers/http/v1/responses/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Into<Vec<u8>> for Compact {
///
/// ```text
/// use std::net::{IpAddr, Ipv4Addr};
/// use torrust_tracker::servers::http::v1::responses::announce::{Normal, NormalPeer};
/// use torrust_tracker_lib::servers::http::v1::responses::announce::{Normal, NormalPeer};
///
/// let peer = NormalPeer {
/// peer_id: *b"-qB00000000000000001",
Expand Down Expand Up @@ -206,7 +206,7 @@ impl From<&NormalPeer> for BencodeMut<'_> {
///
/// ```text
/// use std::net::{IpAddr, Ipv4Addr};
/// use torrust_tracker::servers::http::v1::responses::announce::{Compact, CompactPeer, CompactPeerData};
/// use torrust_tracker_lib::servers::http::v1::responses::announce::{Compact, CompactPeer, CompactPeerData};
///
/// let peer = CompactPeer::V4(CompactPeerData {
/// ip: Ipv4Addr::new(0x69, 0x69, 0x69, 0x69), // 105.105.105.105
Expand Down
2 changes: 1 addition & 1 deletion src/servers/http/v1/responses/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Error {
/// Returns the bencoded representation of the `Error` struct.
///
/// ```text
/// use torrust_tracker::servers::http::v1::responses::error::Error;
/// use torrust_tracker_lib::servers::http::v1::responses::error::Error;
///
/// let err = Error {
/// failure_reason: "error message".to_owned(),
Expand Down
4 changes: 2 additions & 2 deletions src/servers/http/v1/responses/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use crate::core::ScrapeData;
/// The `Scrape` response for the HTTP tracker.
///
/// ```text
/// use torrust_tracker::servers::http::v1::responses::scrape::Bencoded;
/// use torrust_tracker_lib::servers::http::v1::responses::scrape::Bencoded;
/// use bittorrent_primitives::info_hash::InfoHash;
/// use torrust_tracker_primitives::swarm_metadata::SwarmMetadata;
/// use torrust_tracker::core::ScrapeData;
/// use torrust_tracker_lib::core::ScrapeData;
///
/// let info_hash = InfoHash::from_bytes(&[0x69; 20]);
/// let mut scrape_data = ScrapeData::empty();
Expand Down
4 changes: 2 additions & 2 deletions src/servers/http/v1/services/peer_ip_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum PeerIpResolutionError {
/// use std::net::IpAddr;
/// use std::str::FromStr;
///
/// use torrust_tracker::servers::http::v1::services::peer_ip_resolver::{invoke, ClientIpSources, PeerIpResolutionError};
/// use torrust_tracker_lib::servers::http::v1::services::peer_ip_resolver::{invoke, ClientIpSources, PeerIpResolutionError};
///
/// let on_reverse_proxy = true;
///
Expand All @@ -85,7 +85,7 @@ pub enum PeerIpResolutionError {
/// use std::net::IpAddr;
/// use std::str::FromStr;
///
/// use torrust_tracker::servers::http::v1::services::peer_ip_resolver::{invoke, ClientIpSources, PeerIpResolutionError};
/// use torrust_tracker_lib::servers::http::v1::services::peer_ip_resolver::{invoke, ClientIpSources, PeerIpResolutionError};
///
/// let on_reverse_proxy = false;
///
Expand Down
2 changes: 1 addition & 1 deletion tests/common/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::VecDeque;
use std::io;
use std::sync::{Mutex, MutexGuard, Once, OnceLock};

use torrust_tracker::bootstrap::logging::TraceStyle;
use torrust_tracker_lib::bootstrap::logging::TraceStyle;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::fmt::MakeWriter;

Expand Down
10 changes: 5 additions & 5 deletions tests/servers/api/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::sync::Arc;

use bittorrent_primitives::info_hash::InfoHash;
use futures::executor::block_on;
use torrust_tracker::bootstrap::app::initialize_with_configuration;
use torrust_tracker::bootstrap::jobs::make_rust_tls;
use torrust_tracker::core::Tracker;
use torrust_tracker::servers::apis::server::{ApiServer, Launcher, Running, Stopped};
use torrust_tracker::servers::registar::Registar;
use torrust_tracker_configuration::{Configuration, HttpApi};
use torrust_tracker_lib::bootstrap::app::initialize_with_configuration;
use torrust_tracker_lib::bootstrap::jobs::make_rust_tls;
use torrust_tracker_lib::core::Tracker;
use torrust_tracker_lib::servers::apis::server::{ApiServer, Launcher, Running, Stopped};
use torrust_tracker_lib::servers::registar::Registar;
use torrust_tracker_primitives::peer;

use super::connection_info::ConnectionInfo;
Expand Down
4 changes: 2 additions & 2 deletions tests/servers/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use torrust_tracker::core::Tracker;
use torrust_tracker::servers::apis::server;
use torrust_tracker_lib::core::Tracker;
use torrust_tracker_lib::servers::apis::server;

pub mod connection_info;
pub mod environment;
Expand Down
6 changes: 3 additions & 3 deletions tests/servers/api/v1/asserts.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// code-review: should we use macros to return the exact line where the assert fails?

use reqwest::Response;
use torrust_tracker::servers::apis::v1::context::auth_key::resources::AuthKey;
use torrust_tracker::servers::apis::v1::context::stats::resources::Stats;
use torrust_tracker::servers::apis::v1::context::torrent::resources::torrent::{ListItem, Torrent};
use torrust_tracker_lib::servers::apis::v1::context::auth_key::resources::AuthKey;
use torrust_tracker_lib::servers::apis::v1::context::stats::resources::Stats;
use torrust_tracker_lib::servers::apis::v1::context::torrent::resources::torrent::{ListItem, Torrent};

// Resource responses

Expand Down
4 changes: 2 additions & 2 deletions tests/servers/api/v1/contract/context/auth_key.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use serde::Serialize;
use torrust_tracker::core::auth::Key;
use torrust_tracker_lib::core::auth::Key;
use torrust_tracker_test_helpers::configuration;
use uuid::Uuid;

Expand Down Expand Up @@ -462,7 +462,7 @@ async fn should_not_allow_reloading_keys_for_unauthenticated_users() {

mod deprecated_generate_key_endpoint {

use torrust_tracker::core::auth::Key;
use torrust_tracker_lib::core::auth::Key;
use torrust_tracker_test_helpers::configuration;
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion tests/servers/api/v1/contract/context/health_check.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use torrust_tracker::servers::apis::v1::context::health_check::resources::{Report, Status};
use torrust_tracker_lib::servers::apis::v1::context::health_check::resources::{Report, Status};
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down
2 changes: 1 addition & 1 deletion tests/servers/api/v1/contract/context/stats.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::str::FromStr;

use bittorrent_primitives::info_hash::InfoHash;
use torrust_tracker::servers::apis::v1::context::stats::resources::Stats;
use torrust_tracker_lib::servers::apis::v1::context::stats::resources::Stats;
use torrust_tracker_primitives::peer::fixture::PeerBuilder;
use torrust_tracker_test_helpers::configuration;
use uuid::Uuid;
Expand Down
4 changes: 2 additions & 2 deletions tests/servers/api/v1/contract/context/torrent.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::str::FromStr;

use bittorrent_primitives::info_hash::InfoHash;
use torrust_tracker::servers::apis::v1::context::torrent::resources::peer::Peer;
use torrust_tracker::servers::apis::v1::context::torrent::resources::torrent::{self, Torrent};
use torrust_tracker_lib::servers::apis::v1::context::torrent::resources::peer::Peer;
use torrust_tracker_lib::servers::apis::v1::context::torrent::resources::torrent::{self, Torrent};
use torrust_tracker_primitives::peer::fixture::PeerBuilder;
use torrust_tracker_test_helpers::configuration;
use uuid::Uuid;
Expand Down
10 changes: 5 additions & 5 deletions tests/servers/health_check_api/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use torrust_tracker::servers::health_check_api::resources::{Report, Status};
use torrust_tracker::servers::registar::Registar;
use torrust_tracker_lib::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_lib::servers::registar::Registar;
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down Expand Up @@ -32,7 +32,7 @@ async fn health_check_endpoint_should_return_status_ok_when_there_is_no_services
mod api {
use std::sync::Arc;

use torrust_tracker::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_lib::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down Expand Up @@ -142,7 +142,7 @@ mod api {
mod http {
use std::sync::Arc;

use torrust_tracker::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_lib::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down Expand Up @@ -251,7 +251,7 @@ mod http {
mod udp {
use std::sync::Arc;

use torrust_tracker::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_lib::servers::health_check_api::resources::{Report, Status};
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down
8 changes: 4 additions & 4 deletions tests/servers/health_check_api/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::sync::Arc;

use tokio::sync::oneshot::{self, Sender};
use tokio::task::JoinHandle;
use torrust_tracker::bootstrap::jobs::Started;
use torrust_tracker::servers::health_check_api::{server, HEALTH_CHECK_API_LOG_TARGET};
use torrust_tracker::servers::registar::Registar;
use torrust_tracker::servers::signals::{self, Halted};
use torrust_tracker_configuration::HealthCheckApi;
use torrust_tracker_lib::bootstrap::jobs::Started;
use torrust_tracker_lib::servers::health_check_api::{server, HEALTH_CHECK_API_LOG_TARGET};
use torrust_tracker_lib::servers::registar::Registar;
use torrust_tracker_lib::servers::signals::{self, Halted};

#[derive(Debug)]
pub enum Error {
Expand Down
2 changes: 1 addition & 1 deletion tests/servers/http/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::net::IpAddr;

use reqwest::{Client as ReqwestClient, Response};
use torrust_tracker::core::auth::Key;
use torrust_tracker_lib::core::auth::Key;

use super::requests::announce::{self, Query};
use super::requests::scrape;
Expand Down
2 changes: 1 addition & 1 deletion tests/servers/http/connection_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use torrust_tracker::core::auth::Key;
use torrust_tracker_lib::core::auth::Key;

#[derive(Clone, Debug)]
pub struct ConnectionInfo {
Expand Down
10 changes: 5 additions & 5 deletions tests/servers/http/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::sync::Arc;

use bittorrent_primitives::info_hash::InfoHash;
use futures::executor::block_on;
use torrust_tracker::bootstrap::app::initialize_with_configuration;
use torrust_tracker::bootstrap::jobs::make_rust_tls;
use torrust_tracker::core::Tracker;
use torrust_tracker::servers::http::server::{HttpServer, Launcher, Running, Stopped};
use torrust_tracker::servers::registar::Registar;
use torrust_tracker_configuration::{Configuration, HttpTracker};
use torrust_tracker_lib::bootstrap::app::initialize_with_configuration;
use torrust_tracker_lib::bootstrap::jobs::make_rust_tls;
use torrust_tracker_lib::core::Tracker;
use torrust_tracker_lib::servers::http::server::{HttpServer, Launcher, Running, Stopped};
use torrust_tracker_lib::servers::registar::Registar;
use torrust_tracker_primitives::peer;

pub struct Environment<S> {
Expand Down
2 changes: 1 addition & 1 deletion tests/servers/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod v1;
pub type Started = environment::Environment<server::Running>;

use percent_encoding::NON_ALPHANUMERIC;
use torrust_tracker::servers::http::server;
use torrust_tracker_lib::servers::http::server;

pub type ByteArray20 = [u8; 20];

Expand Down
6 changes: 3 additions & 3 deletions tests/servers/http/v1/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn environment_should_be_started_and_stopped() {

mod for_all_config_modes {

use torrust_tracker::servers::http::v1::handlers::health_check::{Report, Status};
use torrust_tracker_lib::servers::http::v1::handlers::health_check::{Report, Status};
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down Expand Up @@ -1381,7 +1381,7 @@ mod configured_as_private {
use std::time::Duration;

use bittorrent_primitives::info_hash::InfoHash;
use torrust_tracker::core::auth::Key;
use torrust_tracker_lib::core::auth::Key;
use torrust_tracker_test_helpers::configuration;

use crate::common::logging;
Expand Down Expand Up @@ -1467,7 +1467,7 @@ mod configured_as_private {

use aquatic_udp_protocol::PeerId;
use bittorrent_primitives::info_hash::InfoHash;
use torrust_tracker::core::auth::Key;
use torrust_tracker_lib::core::auth::Key;
use torrust_tracker_primitives::peer::fixture::PeerBuilder;
use torrust_tracker_test_helpers::configuration;

Expand Down
Loading

0 comments on commit bfaf08b

Please sign in to comment.