Skip to main content

phoenix/
lib.rs

1#[cfg(feature = "auth")]
2pub use phoenix_auth as auth;
3pub use phoenix_config as config;
4pub use phoenix_console as console;
5pub use phoenix_console::commands;
6pub use phoenix_runtime as core;
7pub use phoenix_runtime::applications;
8pub use phoenix_crypto as crypto;
9#[cfg(feature = "database")]
10pub use phoenix_database as database;
11pub use phoenix_dx as dx;
12pub use phoenix_dx::mount_routes;
13pub use phoenix_http as http;
14pub use phoenix_logging as logging;
15pub use phoenix_macros::contract;
16#[cfg(feature = "metrics")]
17pub use phoenix_metrics as metrics;
18pub use phoenix_plugin as plugin;
19pub use phoenix_routing as routing;
20pub use phoenix_routing::routes;
21pub use phoenix_security as security;
22pub use phoenix_validation as validation;
23pub use phoenix_view as view;
24
25#[cfg(feature = "mail")]
26pub use phoenix_mail as mail;
27#[cfg(feature = "queue")]
28pub use phoenix_queue as queue;
29#[cfg(feature = "redis")]
30pub use phoenix_redis as redis;
31#[cfg(feature = "storage")]
32pub use phoenix_storage as storage;
33#[cfg(feature = "testing")]
34pub use phoenix_testing as testing;
35
36pub mod prelude {
37    #[cfg(feature = "auth")]
38    pub use phoenix_auth::{
39        AbacPolicy, AuditReason, AuthorizationAudit, AuthorizationAuditEvent,
40        AuthorizationDecision, AuthorizationEngine, AuthorizationError, AuthorizationRequest,
41        CurrentPrincipal, Permission, PolicyFn, Principal, Rbac, RbacError, RequirePermission,
42        Role, policy_fn,
43    };
44    #[cfg(all(feature = "auth", feature = "jwt"))]
45    pub use phoenix_auth::PrincipalFromJwt;
46    pub use phoenix_config::{AppConfig, AppConfigBuilder, ConfigError, Environment, SecretValue};
47    pub use phoenix_console::{CommandContext, CommandEntry, CommandResult, Console, commands};
48    pub use phoenix_runtime::applications;
49    pub use phoenix_runtime::{
50        Application, ApplicationModule, HttpProtocol, MultiApplicationBuilder,
51        MultiApplicationError, Server, ServerError, ServerHandle,
52    };
53    #[cfg(feature = "tls")]
54    pub use phoenix_runtime::{TlsConfig, TlsConfigError};
55    pub use phoenix_crypto::{
56        BlindIndexError, BlindIndexKey, BlindIndexer, Ciphertext,
57        EncryptionError as CryptoEncryptionError, EncryptionKey, Encryptor, MAX_BLIND_INDEX_KEYS,
58    };
59    #[cfg(feature = "jwt")]
60    pub use phoenix_crypto::{
61        FileTokenStore, Jwt, JwtAuth, JwtClaims, JwtConfig, JwtError, JwtKey, JwtManager,
62        MemoryTokenStore, RefreshRecord, RotateRefresh, StatefulJwtAuth, TokenError, TokenPair,
63        TokenService, TokenStore, TokenStoreError,
64    };
65    #[cfg(feature = "password")]
66    pub use phoenix_crypto::{Password, PasswordError};
67    #[cfg(feature = "database")]
68    pub use phoenix_database::{Backend, Database, DatabaseBuilder, DatabaseError, TestDatabase};
69    pub use phoenix_dx::{
70        Bound, MiddlewareAliasError, MiddlewareAliases, ModelBinding, Resource, ResourceAction,
71        ResourceRoutes, mount_routes,
72    };
73    pub use phoenix_http::{
74        BoxFuture, ByteStream, ConnectionInfo, CspNonce, Download, Form, FormRejection,
75        FromMultipart, FromRequest, Handler, Header, HeaderRejection, IntoResponse, InvalidCspNonce,
76        Json, JsonRejection, Method, Middleware, Mime, Multipart, MultipartData, MultipartField,
77        MultipartRejection, Next, Path, PathRejection, Query, QueryRejection, Redirect, Request,
78        RequestBodyError, RequestBodyMode, RequestBodyStream, RequestBodyStreamRejection, Response,
79        ResponseBody, ResponseContext, RouteManifest, SecurityHeaders, State, StateMiddleware,
80        StateRejection, StatusCode, StreamingHandler, TransportScheme, TypedHandler, Uri, Version,
81        middleware_fn, streaming, typed,
82    };
83    #[cfg(feature = "sse")]
84    pub use phoenix_http::{
85        InvalidSseField, KeepAlive, LastEventId, LastEventIdRejection, Sse, SseConfigError,
86        SseEvent,
87    };
88    #[cfg(feature = "websocket")]
89    pub use phoenix_http::{
90        CloseCode, CloseFrame, Message, WebSocket, WebSocketConfigError, WebSocketError,
91        WebSocketUpgrade, WebSocketUpgradeRejection,
92    };
93    // ConnectionUpgrade is always available for Hyper upgrades.
94    pub use phoenix_http::ConnectionUpgrade;
95    pub use phoenix_logging::{LogFormat, Logging, LoggingError, LoggingGuard};
96    #[cfg(feature = "metrics")]
97    pub use phoenix_metrics::{
98        DatabaseOutcome, JobOutcome, Metrics, MetricsMiddleware, RendererMetricsSnapshot,
99    };
100    pub use phoenix_plugin::{Capability, FeatureError, FeatureParts, FeatureSet, Plugin};
101    pub use phoenix_routing::routes;
102    pub use phoenix_routing::{
103        ApplicationContext, MultiRouterError, RouteBuildError, RouteGroup, Router, Routes,
104        UrlGenerationError,
105    };
106    pub use phoenix_security::{
107        AccessLog, ClientIp, ClientIpRateLimitKey, Cors, CorsConfig, CspPolicyError, Csrf,
108        EffectiveScheme, HostAllowlist, HttpsRedirect, HttpsRedirectError, MemoryRateLimitBackend,
109        MemorySessionBackend, NonceSecurityPolicy, RateLimit, RateLimitBackend, RateLimitConfig,
110        RateLimitDecision, RateLimitFailureMode, RateLimitKey, RateLimitStoreError, RequestId,
111        RequestIdValue, SameSite, SecurityPolicy, Session, SessionBackend, SessionBackendError,
112        SessionConfig, SessionMiddleware, SessionSnapshot, SessionStore, SessionWrite,
113        TrustedProxies, effective_scheme,
114    };
115    pub use phoenix_validation::{
116        BoxedRule, Rule, RuleContext, Validate, Validated, ValidatedRejection, ValidationError,
117        ValidationErrors, Validator, custom_rule, max_length, min_length, required, rules, string,
118    };
119    pub use phoenix_view::{
120        ASSET_MANIFEST_SCHEMA, Aes256GcmCodec, AssetEntry, AssetManifest, AssetManifestError,
121        DocumentContext, DocumentSlots, DocumentTemplate, DocumentTemplateError, EncryptionError,
122        Island, NodeRenderer, OpenGraph, Page, PageEnvelope, PageHead, PageResponseError,
123        PayloadCodec, RenderContext, RenderFrame, RenderMode, RenderResult, RendererConfig,
124        RendererError, RendererHealth, RendererManifest, RendererStream, ServeProductionAssets,
125        TrustedHtml,
126    };
127
128    #[cfg(feature = "mail")]
129    pub use phoenix_mail::{
130        Address, MailError, MailTransport, Mailer, MemoryTransport, Message as EmailMessage,
131        MessageBuilder,
132    };
133    #[cfg(feature = "queue")]
134    pub use phoenix_queue::{
135        JobEnvelope, JobError, JobHandler, JobId, MemoryQueue, PushOptions, PushResult, Queue,
136        QueueBackend, QueueError, ShutdownSignal, ShutdownToken, Worker, WorkerConfig,
137    };
138    #[cfg(feature = "redis")]
139    pub use phoenix_redis::{
140        RedisBackends, RedisConnectError, RedisRateLimitBackend, RedisSessionBackend, RedisStores,
141    };
142    #[cfg(all(feature = "redis", feature = "jwt"))]
143    pub use phoenix_redis::RedisTokenStore;
144    #[cfg(feature = "storage")]
145    pub use phoenix_storage::{LocalDisk, Storage, StorageError, sanitize_key};
146    #[cfg(feature = "testing")]
147    pub use phoenix_testing::{
148        IntoApplication, RequestBuilder, TestApp, TestAppError, TestResponse,
149    };
150}