Skip to content

Commit

Permalink
Fixup privacy. Adjust visibility to be pub(crate) as much as possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
onelson committed Jun 7, 2021
1 parent f079b85 commit 484bd5e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ impl From<PackageVersion> for NewCrate {
}
}

/// Get a list of crate names, with their latest version numbers.
/// Get a list of crate names, with their latest version numbers and publish
/// timestamps.
///
/// If all versions of a given crate have been yanked, it will be omitted from
/// this listing entirely.
Expand Down
13 changes: 5 additions & 8 deletions src/handlers/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
//! The endpoints here aim to support whatever is necessary for "git fetch" to
//! work so cargo can do what it needs.
use crate::errors::EstuaryError;
use crate::Settings;
use crate::{Result, Settings};
use actix_web::{get, post, web, HttpResponse};
use serde::Deserialize;
use std::io::Write;
use std::process::{Command, Stdio};

type Result<T> = std::result::Result<T, EstuaryError>;

/// Prefixes the string with 4 bytes representing the hex length of the string.
///
/// The lines git's response bodies use a packet protocol where the first 4
Expand All @@ -28,7 +25,7 @@ fn pkt_line(s: &str) -> String {

/// Git "services" offered by our transport.
#[derive(Deserialize)]
pub enum Service {
pub(crate) enum Service {
#[serde(rename = "git-upload-pack")]
UploadPack,
}
Expand All @@ -42,12 +39,12 @@ impl Service {
}

#[derive(Deserialize)]
pub struct Query {
pub(crate) struct Query {
service: Service,
}

#[get("/info/refs")]
pub async fn get_info_refs(
pub(crate) async fn get_info_refs(
settings: web::Data<Settings>,
query: web::Query<Query>,
) -> Result<HttpResponse> {
Expand Down Expand Up @@ -85,7 +82,7 @@ pub async fn get_info_refs(
}

#[post("/git-upload-pack")]
pub async fn upload_pack(
pub(crate) async fn upload_pack(
settings: web::Data<Settings>,
payload: web::Bytes,
) -> Result<HttpResponse> {
Expand Down
16 changes: 8 additions & 8 deletions src/handlers/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ use std::sync::Mutex;
pub type ApiResponse = Result<HttpResponse, ApiError>;

#[derive(Deserialize)]
pub struct Crate {
pub(crate) struct Crate {
crate_name: String,
version: semver::Version,
}

#[put("/new")]
pub async fn publish(
pub(crate) async fn publish(
mut payload: web::Bytes,
package_index: web::Data<Mutex<PackageIndex>>,
settings: web::Data<Settings>,
Expand Down Expand Up @@ -89,7 +89,7 @@ pub async fn publish(
}

#[delete("/{crate_name}/{version}/yank")]
pub async fn yank(
pub(crate) async fn yank(
path: web::Path<Crate>,
package_index: web::Data<Mutex<PackageIndex>>,
) -> ApiResponse {
Expand All @@ -100,7 +100,7 @@ pub async fn yank(
}

#[put("/{crate_name}/{version}/unyank")]
pub async fn unyank(
pub(crate) async fn unyank(
path: web::Path<Crate>,
package_index: web::Data<Mutex<PackageIndex>>,
) -> ApiResponse {
Expand All @@ -111,7 +111,7 @@ pub async fn unyank(
}

#[get("/{crate_name}/{version}/download")]
pub async fn download(
pub(crate) async fn download(
path: web::Path<Crate>,
settings: web::Data<Settings>,
) -> actix_web::Result<fs::NamedFile> {
Expand All @@ -129,7 +129,7 @@ pub async fn download(
///
/// <https://doc.rust-lang.org/nightly/cargo/reference/registries.html#search>
#[derive(Deserialize, Debug)]
pub struct SearchQuery {
pub(crate) struct SearchQuery {
/// The search terms to match on.
q: String,
/// default=10, max=100.
Expand All @@ -140,14 +140,14 @@ pub struct SearchQuery {
}

#[derive(Serialize, Debug)]
pub struct SearchResult {
pub(crate) struct SearchResult {
name: String,
max_version: semver::Version,
description: String,
}

#[get("")]
pub async fn search(
pub(crate) async fn search(
query: web::Query<SearchQuery>,
index: web::Data<Mutex<PackageIndex>>,
) -> ApiResponse {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ mod handlers;
mod package_index;
mod storage;

type Result<T> = std::result::Result<T, EstuaryError>;
pub(crate) type Result<T> = std::result::Result<T, EstuaryError>;

/// Common configuration details to share with handlers.
#[derive(Clone, Debug)]
pub struct Settings {
pub(crate) struct Settings {
/// Root path for storing `.crate` files when they are published.
pub crate_dir: PathBuf,
/// Location for the git repo that tracks changes to the package index.
Expand Down
2 changes: 1 addition & 1 deletion src/package_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct PackageVersion {
}

impl PackageVersion {
pub fn from_new_crate(new_crate: &NewCrate, cksum: &str) -> crate::Result<Self> {
pub(crate) fn from_new_crate(new_crate: &NewCrate, cksum: &str) -> crate::Result<Self> {
let mut deps = Vec::with_capacity(new_crate.deps.len());
for new_crate_dep in new_crate.deps.clone() {
deps.push(new_crate_dep.try_into()?);
Expand Down

0 comments on commit 484bd5e

Please sign in to comment.