Skip to main content

Crate capy_core

Crate capy_core 

Source
Expand description

Typed configuration, shared application state, and safe application errors.

Structs§

ApiErrorResponse
JSON wire envelope for Capy’s standardized errors. It never carries native causes.
ApiSettings
Small application-owned API metadata. Documentation is disabled by default.
AppConfig
Application and database settings, resolved before startup.
AppContext
Cheaply cloned state shared by every request.
AppSettings
HTTP server and logging settings. Environment variables use APP_.
AuthSettings
Small, typed settings for the optional conventional identity system.
AuthThrottleLimit
Fixed-window abuse budget. Zero never implicitly disables a limit.
AuthThrottleSettings
Separate fixed windows for CSRF bootstrap, registration, login, reset request and reset completion. Limits apply per action; account keys span client IPs. Application-owned verification endpoints need their own request-level limiter.
ClientIpResolver
Validated, reusable resolver. Forged headers from untrusted peers are ignored. Trusted chains are walked right to left; the first untrusted address is the client. Missing/ambiguous identities fail closed with a generic 503, never a shared bucket.
ClientIpSettings
Client identity policy under [client_ip] in config/http.toml.
Context
Extract typed application state using Context(ctx): Context.
DatabaseSettings
SeaORM connection settings. Environment variables use DATABASE_.
ErrorKind
Safe error category carried on an HTTP response for request diagnostics.
EventBus
Extract the same registry installed by App::on for application-owned transitions.
EventContext
Transaction-oriented services. No application pool is exposed. Reuse transaction for repository calls and ctx.jobs().dispatch(job) (with the jobs extension trait) for atomic enqueue. Avoid network I/O and capturing a pool: reacquiring a connection can deadlock even on PostgreSQL when its pool is full.
Events
Immutable, cheaply cloned registration snapshot. Each listener is called once per dispatch, in registration order. The first rejection/failure stops dispatch; the owner MUST roll back. Cancellation also requires rollback. Only explicit EventError::Reject values become public application errors. Unexpected errors and unwinding panics become a generic 500 (panic=abort still aborts the process).
HttpSettings
Small HTTP policy surface, expressed in seconds and bytes to avoid ambiguous units.
JobsSettings
Durable worker policy. Jobs are activated by App::jobs, never implicitly.
MailSecret
A configuration credential. Debug is redacted; serialization is for config merging.
MailSettings
Conventional outbound mail settings; activated by App::mail.
PasswordSettings
Per-application Argon2id admission and resource limits (AUTH_PASSWORD_*).
ServerSettings
Listener settings. Unspecified host/port retain legacy APP_HOST/APP_PORT.
Service
Extract a typed registered service from an HTTP request.
Services
Immutable, cheaply cloned application dependencies keyed by their Rust type. Each application factory owns its registry; there is no process-wide state.
SmtpSettings
SMTP settings. TLS is mandatory in production; no opportunistic downgrade.
StorageSettings
Optional private object-store configuration (config/storage.toml, STORAGE_*).

Enums§

AppError
Errors with predictable HTTP statuses and safe public messages.
ClientIpStrategy
Exactly one trusted header convention; no fallback between competing headers.
EventError
Listener outcome. Only Reject exposes application-authored public text. ? on database/anyhow/unexpected application errors takes the private failure path. A nested operation’s already-typed AppError::Rejected remains a rejection.
EventRejection
An intentional, public application policy rejection. Only these statuses may be exposed by listeners. Codes and messages must be static, safe application text, never dependency errors, credentials or account-existence diagnostics.
HashConcurrency
Automatic hardware/budget selection or an explicit worker count.
SameSite
Cookie policy. Cross-site cookies are intentionally outside the built-in path.

Traits§

Event
Explicit opt-in to transactional application events. No serialization is required. Event values must not contain passwords, session/CSRF credentials or reset tokens.

Type Aliases§

EventFuture
A listener future borrowing the event, configuration and native transaction.
EventResult
Result returned by a transactional lifecycle listener.
Result
The result type used by application handlers and startup.
ValidationErrors
Field names (including dotted nested paths) mapped to validation messages.