pub struct State { /* private fields */ }Expand description
Bundle of optional connection handles. Cheap to clone — all inner types are reference-counted.
Implementations§
Source§impl State
impl State
Sourcepub async fn with_storage<S: StorageProvider>(self, storage: S) -> Result<Self>
pub async fn with_storage<S: StorageProvider>(self, storage: S) -> Result<Self>
Attach a custom StorageProvider. Probes it immediately and
returns the error if the probe fails — same contract as the
other backends (“fail fast at boot”).
Sourcepub fn set_storage(&mut self, storage: Arc<dyn StorageProvider>)
pub fn set_storage(&mut self, storage: Arc<dyn StorageProvider>)
Attach a pre-boxed provider without re-probing. Use when the caller has already done their own validation, or when injecting a mock from tests.
Sourcepub fn has_storage(&self) -> bool
pub fn has_storage(&self) -> bool
Whether a storage provider is wired.
Sourcepub fn storage(&self) -> Result<&Arc<dyn StorageProvider>>
pub fn storage(&self) -> Result<&Arc<dyn StorageProvider>>
Borrow the trait-object storage handle. Returns a Config error
if no provider was wired (scaffold without --with-storage, or
STORAGE_BUCKET unset in the generated init).
Sourcepub async fn from_env() -> Result<Self>
pub async fn from_env() -> Result<Self>
Build a State from environment variables. Tries each backend
independently; missing env vars produce None fields, not
errors. Connection failures DO error — if DATABASE_URL is set
but unreachable, that’s a deploy-time problem and the service
should fail to start.
Object storage is not initialized here — its concrete client
type (opendal::Operator, AWS SDK, etc.) is scaffold-time opt-in,
so this framework crate doesn’t pull those deps. The scaffolded
main.rs calls State::with_storage separately when
--with-storage was used.
Sourcepub fn pg(&self) -> Result<&PgPool>
pub fn pg(&self) -> Result<&PgPool>
Borrow the Postgres pool. Returns a Config error if
DATABASE_URL was not set at boot.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl !RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl !UnwindSafe for State
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request