Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/lib/src/helmet/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub trait Policy: Default + Send + Sync + 'static {
fn header(&self) -> Header<'static>;
}

crate trait SubPolicy: Send + Sync {
pub(crate) trait SubPolicy: Send + Sync {
fn name(&self) -> &'static UncasedStr;
fn header(&self) -> Header<'static>;
}
Expand Down
2 changes: 0 additions & 2 deletions contrib/lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(crate_visibility_modifier)]

#![doc(html_root_url = "https://api.rocket.rs/v0.5")]
#![doc(html_favicon_url = "https://rocket.rs/v0.5/images/favicon.ico")]
#![doc(html_logo_url = "https://rocket.rs/v0.5/images/logo-boxed.png")]
Expand Down
8 changes: 4 additions & 4 deletions contrib/lib/src/templates/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use crate::templates::{Engines, TemplateInfo};

use rocket::http::ContentType;

crate struct Context {
pub(crate) struct Context {
/// The root of the template directory.
crate root: PathBuf,
pub root: PathBuf,
/// Mapping from template name to its information.
crate templates: HashMap<String, TemplateInfo>,
pub templates: HashMap<String, TemplateInfo>,
/// Loaded template engines
crate engines: Engines,
pub engines: Engines,
}

impl Context {
Expand Down
8 changes: 4 additions & 4 deletions contrib/lib/src/templates/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::templates::TemplateInfo;
#[cfg(feature = "tera_templates")] use crate::templates::tera::Tera;
#[cfg(feature = "handlebars_templates")] use crate::templates::handlebars::Handlebars;

crate trait Engine: Send + Sync + 'static {
pub(crate) trait Engine: Send + Sync + 'static {
const EXT: &'static str;

fn init(templates: &[(&str, &TemplateInfo)]) -> Option<Self> where Self: Sized;
Expand Down Expand Up @@ -60,12 +60,12 @@ pub struct Engines {
}

impl Engines {
crate const ENABLED_EXTENSIONS: &'static [&'static str] = &[
pub(crate) const ENABLED_EXTENSIONS: &'static [&'static str] = &[
#[cfg(feature = "tera_templates")] Tera::EXT,
#[cfg(feature = "handlebars_templates")] Handlebars::EXT,
];

crate fn init(templates: &HashMap<String, TemplateInfo>) -> Option<Engines> {
pub(crate) fn init(templates: &HashMap<String, TemplateInfo>) -> Option<Engines> {
fn inner<E: Engine>(templates: &HashMap<String, TemplateInfo>) -> Option<E> {
let named_templates = templates.iter()
.filter(|&(_, i)| i.extension == E::EXT)
Expand All @@ -89,7 +89,7 @@ impl Engines {
})
}

crate fn render<C: Serialize>(
pub(crate) fn render<C: Serialize>(
&self,
name: &str,
info: &TemplateInfo,
Expand Down
22 changes: 11 additions & 11 deletions contrib/lib/src/templates/fairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rocket::Rocket;
use rocket::config::ConfigError;
use rocket::fairing::{Fairing, Info, Kind};

crate use self::context::ContextManager;
pub(crate) use self::context::ContextManager;

#[cfg(not(debug_assertions))]
mod context {
Expand All @@ -13,18 +13,18 @@ mod context {

/// Wraps a Context. With `cfg(debug_assertions)` active, this structure
/// additionally provides a method to reload the context at runtime.
crate struct ContextManager(Context);
pub(crate) struct ContextManager(Context);

impl ContextManager {
crate fn new(ctxt: Context) -> ContextManager {
pub fn new(ctxt: Context) -> ContextManager {
ContextManager(ctxt)
}

crate fn context<'a>(&'a self) -> impl Deref<Target=Context> + 'a {
pub fn context<'a>(&'a self) -> impl Deref<Target=Context> + 'a {
&self.0
}

crate fn is_reloading(&self) -> bool {
pub fn is_reloading(&self) -> bool {
false
}
}
Expand All @@ -42,15 +42,15 @@ mod context {

/// Wraps a Context. With `cfg(debug_assertions)` active, this structure
/// additionally provides a method to reload the context at runtime.
crate struct ContextManager {
pub(crate) struct ContextManager {
/// The current template context, inside an RwLock so it can be updated.
context: RwLock<Context>,
/// A filesystem watcher and the receive queue for its events.
watcher: Option<Mutex<(RecommendedWatcher, Receiver<RawEvent>)>>,
}

impl ContextManager {
crate fn new(ctxt: Context) -> ContextManager {
pub fn new(ctxt: Context) -> ContextManager {
let (tx, rx) = channel();
let watcher = raw_watcher(tx).and_then(|mut watcher| {
watcher.watch(ctxt.root.canonicalize()?, RecursiveMode::Recursive)?;
Expand All @@ -73,11 +73,11 @@ mod context {
}
}

crate fn context(&self) -> impl Deref<Target=Context> + '_ {
pub fn context(&self) -> impl Deref<Target=Context> + '_ {
self.context.read().unwrap()
}

crate fn is_reloading(&self) -> bool {
pub fn is_reloading(&self) -> bool {
self.watcher.is_some()
}

Expand All @@ -89,7 +89,7 @@ mod context {
/// have been changes since the last reload, all templates are
/// reinitialized from disk and the user's customization callback is run
/// again.
crate fn reload_if_needed<F: Fn(&mut Engines)>(&self, custom_callback: F) {
pub fn reload_if_needed<F: Fn(&mut Engines)>(&self, custom_callback: F) {
self.watcher.as_ref().map(|w| {
let rx_lock = w.lock().expect("receive queue lock");
let mut changed = false;
Expand Down Expand Up @@ -121,7 +121,7 @@ pub struct TemplateFairing {
/// The user-provided customization callback, allowing the use of
/// functionality specific to individual template engines. In debug mode,
/// this callback might be run multiple times as templates are reloaded.
crate custom_callback: Box<dyn Fn(&mut Engines) + Send + Sync + 'static>,
pub custom_callback: Box<dyn Fn(&mut Engines) + Send + Sync + 'static>,
}

impl Fairing for TemplateFairing {
Expand Down
6 changes: 3 additions & 3 deletions contrib/lib/src/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ mod metadata;

pub use self::engine::Engines;
pub use self::metadata::Metadata;
crate use self::context::Context;
crate use self::fairing::ContextManager;
pub(crate) use self::context::Context;
pub(crate) use self::fairing::ContextManager;

use self::engine::Engine;
use self::fairing::TemplateFairing;
Expand Down Expand Up @@ -209,7 +209,7 @@ pub struct Template {
}

#[derive(Debug)]
crate struct TemplateInfo {
pub(crate) struct TemplateInfo {
/// The complete path, including `template_dir`, to this template.
path: PathBuf,
/// The extension for the engine of this template.
Expand Down
18 changes: 9 additions & 9 deletions core/codegen/src/attribute/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use crate::http::uri::{UriPart, Path};
use crate::http::route::RouteSegment;
use crate::proc_macro_ext::{Diagnostics, StringLit, PResult, DResult};

crate use crate::http::route::{Error, Kind, Source};
pub use crate::http::route::{Error, Kind, Source};

#[derive(Debug, Clone)]
crate struct Segment {
crate span: Span,
crate kind: Kind,
crate source: Source,
crate name: String,
crate index: Option<usize>,
pub struct Segment {
pub span: Span,
pub kind: Kind,
pub source: Source,
pub name: String,
pub index: Option<usize>,
}

impl Segment {
Expand Down Expand Up @@ -115,7 +115,7 @@ fn into_diagnostic(
}
}

crate fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
pub fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
<RouteSegment<'_, Path>>::parse_one(segment)
.map(|segment| {
let mut seg = Segment::from(segment, span);
Expand All @@ -126,7 +126,7 @@ crate fn parse_data_segment(segment: &str, span: Span) -> PResult<Segment> {
.map_err(|e| into_diagnostic(segment, segment, span, &e))
}

crate fn parse_segments<P: UriPart>(
pub fn parse_segments<P: UriPart>(
string: &str,
span: Span
) -> DResult<Vec<Segment>> {
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/src/bang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{ROUTE_STRUCT_PREFIX, CATCH_STRUCT_PREFIX};
mod uri;
mod uri_parsing;

crate fn prefix_last_segment(path: &mut Path, prefix: &str) {
pub fn prefix_last_segment(path: &mut Path, prefix: &str) {
let mut last_seg = path.segments.last_mut().expect("syn::Path has segments");
last_seg.ident = last_seg.ident.prepend(prefix);
}
Expand Down
4 changes: 2 additions & 2 deletions core/codegen/src/bang/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ macro_rules! p {
($n:expr, "parameter") => (p!(@go $n, "1 parameter", format!("{} parameters", $n)));
}

crate fn _uri_macro(input: TokenStream) -> Result<TokenStream> {
pub fn _uri_macro(input: TokenStream) -> Result<TokenStream> {
let input2: TokenStream2 = input.clone().into();
let mut params = syn::parse::<UriParams>(input).map_err(syn_to_diag)?;
prefix_last_segment(&mut params.route_path, URI_MACRO_PREFIX);
Expand Down Expand Up @@ -212,7 +212,7 @@ fn build_origin(internal: &InternalUriParams) -> Origin<'static> {
Origin::new(path, query).to_normalized().into_owned()
}

crate fn _uri_internal_macro(input: TokenStream) -> Result<TokenStream> {
pub fn _uri_internal_macro(input: TokenStream) -> Result<TokenStream> {
// Parse the internal invocation and the user's URI param expressions.
let internal = syn::parse::<InternalUriParams>(input).map_err(syn_to_diag)?;
let (path_params, query_params) = extract_exprs(&internal)?;
Expand Down
10 changes: 5 additions & 5 deletions core/codegen/src/derive/from_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use proc_macro::{Span, TokenStream};
use devise::{*, ext::{TypeExt, Split3}};

#[derive(FromMeta)]
crate struct Form {
crate field: FormField,
pub struct Form {
pub field: FormField,
}

crate struct FormField {
crate span: Span,
crate name: String
pub struct FormField {
pub span: Span,
pub name: String
}

fn is_valid_field_name(s: &str) -> bool {
Expand Down
22 changes: 11 additions & 11 deletions core/codegen/src/http_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ use crate::attribute::segments::{parse_segments, parse_data_segment, Segment, Ki
use crate::proc_macro_ext::StringLit;

#[derive(Debug)]
crate struct ContentType(crate http::ContentType);
pub struct ContentType(pub http::ContentType);

#[derive(Debug)]
crate struct Status(crate http::Status);
pub struct Status(pub http::Status);

#[derive(Debug)]
crate struct MediaType(crate http::MediaType);
pub struct MediaType(pub http::MediaType);

#[derive(Debug)]
crate struct Method(crate http::Method);
pub struct Method(pub http::Method);

#[derive(Debug)]
crate struct Origin(crate http::uri::Origin<'static>);
pub struct Origin(pub http::uri::Origin<'static>);

#[derive(Clone, Debug)]
crate struct DataSegment(crate Segment);
pub struct DataSegment(pub Segment);

#[derive(Clone, Debug)]
crate struct Optional<T>(crate Option<T>);
pub struct Optional<T>(pub Option<T>);

impl FromMeta for StringLit {
fn from_meta(meta: MetaItem<'_>) -> Result<Self> {
Expand All @@ -35,10 +35,10 @@ impl FromMeta for StringLit {
}

#[derive(Debug)]
crate struct RoutePath {
crate origin: Origin,
crate path: Vec<Segment>,
crate query: Option<Vec<Segment>>,
pub struct RoutePath {
pub origin: Origin,
pub path: Vec<Segment>,
pub query: Option<Vec<Segment>>,
}

impl FromMeta for Status {
Expand Down
15 changes: 7 additions & 8 deletions core/codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(proc_macro_diagnostic, proc_macro_span)]
#![feature(crate_visibility_modifier)]
#![recursion_limit="128"]

#![doc(html_root_url = "https://api.rocket.rs/v0.5")]
Expand Down Expand Up @@ -114,14 +113,14 @@ mod syn_ext;

use crate::http::Method;
use proc_macro::TokenStream;
crate use devise::proc_macro2;
pub(crate) use devise::proc_macro2;

Comment thread
jhpratt marked this conversation as resolved.
crate static ROUTE_STRUCT_PREFIX: &str = "static_rocket_route_info_for_";
crate static CATCH_STRUCT_PREFIX: &str = "static_rocket_catch_info_for_";
crate static CATCH_FN_PREFIX: &str = "rocket_catch_fn_";
crate static ROUTE_FN_PREFIX: &str = "rocket_route_fn_";
crate static URI_MACRO_PREFIX: &str = "rocket_uri_macro_";
crate static ROCKET_PARAM_PREFIX: &str = "__rocket_param_";
pub(crate) static ROUTE_STRUCT_PREFIX: &str = "static_rocket_route_info_for_";
Comment thread
jebrosen marked this conversation as resolved.
Outdated
pub(crate) static CATCH_STRUCT_PREFIX: &str = "static_rocket_catch_info_for_";
pub(crate) static CATCH_FN_PREFIX: &str = "rocket_catch_fn_";
pub(crate) static ROUTE_FN_PREFIX: &str = "rocket_route_fn_";
pub(crate) static URI_MACRO_PREFIX: &str = "rocket_uri_macro_";
pub(crate) static ROCKET_PARAM_PREFIX: &str = "__rocket_param_";

macro_rules! emit {
($tokens:expr) => ({
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/src/proc_macro_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl From<Vec<Diagnostic>> for Diagnostics {

use std::ops::Deref;

pub struct StringLit(crate String, crate Literal);
pub struct StringLit(pub String, pub Literal);

impl Deref for StringLit {
type Target = str;
Expand Down
2 changes: 1 addition & 1 deletion core/http/src/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl PartialEq for AcceptParams {
/// let response = Response::build().header(Accept::JSON).finalize();
/// ```
#[derive(Debug, Clone, PartialEq)]
pub struct Accept(crate AcceptParams);
pub struct Accept(pub(crate) AcceptParams);

macro_rules! accept_constructor {
($($name:ident ($check:ident): $str:expr, $t:expr,
Expand Down
3 changes: 1 addition & 2 deletions core/http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(crate_visibility_modifier)]
#![recursion_limit="512"]

#![warn(rust_2018_idioms)]
Expand Down Expand Up @@ -38,7 +37,7 @@ mod header;
mod accept;
mod raw_str;

crate mod parse;
pub(crate) mod parse;

pub mod uncased;

Expand Down
2 changes: 1 addition & 1 deletion core/http/src/parse/uri/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum Or<L, R> {
}

impl<'a> Error<'a> {
crate fn from(src: &'a str, pear_error: ParseErr<RawInput<'a>>) -> Error<'a> {
pub fn from(src: &'a str, pear_error: ParseErr<RawInput<'a>>) -> Error<'a> {
let new_expected = pear_error.expected.map(|token| {
if token.is_ascii() && !token.is_ascii_control() {
Or::A(token as char)
Expand Down
2 changes: 1 addition & 1 deletion core/http/src/parse/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::uri::{Uri, Origin, Absolute, Authority};
use crate::parse::indexed::IndexedInput;
use self::parser::{uri, origin, authority_only, absolute_only, rocket_route_origin};

crate use self::tables::is_pchar;
pub use self::tables::is_pchar;
pub use self::error::Error;

type RawInput<'a> = IndexedInput<'a, [u8]>;
Expand Down
Loading