pub struct AdvancedAdapter { /* private fields */ }Expand description
A more complex adapter showing advanced validation and configuration.
This example demonstrates:
- Complex field validation with predicates
- Multiple configuration sources
- Environment variable handling
- INI override patterns
ⓘ
let adapter = AdvancedAdapter::new()
.with_database_url("postgres://localhost:5432/mydb")
.with_max_connections(50)
.with_debug_mode(true)
.with_env("CUSTOM_VAR", "value");
let context = adapter.build(script_path)?;Implementations§
Source§impl AdvancedAdapter
impl AdvancedAdapter
Sourcepub fn with_database_url(self, url: impl Into<String>) -> Self
pub fn with_database_url(self, url: impl Into<String>) -> Self
Set the database connection URL.
Sourcepub fn with_max_connections(self, max: u32) -> Self
pub fn with_max_connections(self, max: u32) -> Self
Set the maximum database connections.
Sourcepub fn with_debug_mode(self, debug: bool) -> Self
pub fn with_debug_mode(self, debug: bool) -> Self
Enable or disable debug mode.
Sourcepub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an environment variable.
Sourcepub fn with_working_dir(self, path: impl Into<PathBuf>) -> Self
pub fn with_working_dir(self, path: impl Into<PathBuf>) -> Self
Set the working directory.
Trait Implementations§
Source§impl PhpSapiAdapter for AdvancedAdapter
impl PhpSapiAdapter for AdvancedAdapter
Source§fn build(
self,
script_path: impl AsRef<Path>,
) -> Result<ExecutionContext, AdapterError>
fn build( self, script_path: impl AsRef<Path>, ) -> Result<ExecutionContext, AdapterError>
Build an execution context from the configured adapter. Read more
Source§fn validate_script_path(
script_path: impl AsRef<Path>,
) -> Result<PathBuf, AdapterError>where
Self: Sized,
fn validate_script_path(
script_path: impl AsRef<Path>,
) -> Result<PathBuf, AdapterError>where
Self: Sized,
Validate that a script path exists and is accessible. Read more
Source§fn validate_non_empty(field_name: &str, value: &str) -> Result<(), AdapterError>where
Self: Sized,
fn validate_non_empty(field_name: &str, value: &str) -> Result<(), AdapterError>where
Self: Sized,
Validate a configuration field is not empty. Read more
Auto Trait Implementations§
impl Freeze for AdvancedAdapter
impl RefUnwindSafe for AdvancedAdapter
impl Send for AdvancedAdapter
impl Sync for AdvancedAdapter
impl Unpin for AdvancedAdapter
impl UnwindSafe for AdvancedAdapter
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
Mutably borrows from an owned value. Read more