pub struct ConcurrencyConfig { /* private fields */ }Expand description
Concurrency configuration with smart auto-detection
Provides intelligent defaults based on hardware capabilities:
- Auto-detection: Uses
std::thread::available_parallelism()to detect CPU cores - HDD-aware: Limits concurrency on systems with limited I/O
- Safe bounds: Clamps values between 1 and 16
§Examples
use rust_scraper::ConcurrencyConfig;
// Auto-detect (default)
let config = ConcurrencyConfig::default();
// Explicit value
let config = ConcurrencyConfig::new(5);
// Get the resolved value
let concurrency = config.resolve();
println!("Using {} concurrent workers", concurrency);Implementations§
Source§impl ConcurrencyConfig
impl ConcurrencyConfig
Sourcepub fn auto() -> Self
pub fn auto() -> Self
Create auto-detecting config (default)
§Examples
use rust_scraper::ConcurrencyConfig;
let config = ConcurrencyConfig::auto();
let concurrency = config.resolve();
assert!(concurrency >= 1);Sourcepub fn resolve(&self) -> usize
pub fn resolve(&self) -> usize
Resolve the actual concurrency value
Uses auto-detection based on CPU cores:
- 1-2 cores: 1 (avoid overwhelming system)
- 4 cores: 3 (HDD-aware default)
- 8+ cores: min(cores - 1, 8)
§Returns
Concurrency value between 1 and 16
§Examples
use rust_scraper::ConcurrencyConfig;
// Explicit value
let config = ConcurrencyConfig::new(5);
assert_eq!(config.resolve(), 5);
// Auto-detect
let config = ConcurrencyConfig::auto();
let value = config.resolve();
assert!(value >= 1 && value <= 16);Trait Implementations§
Source§impl Clone for ConcurrencyConfig
impl Clone for ConcurrencyConfig
Source§fn clone(&self) -> ConcurrencyConfig
fn clone(&self) -> ConcurrencyConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConcurrencyConfig
impl Debug for ConcurrencyConfig
Source§impl Default for ConcurrencyConfig
impl Default for ConcurrencyConfig
Source§impl Display for ConcurrencyConfig
impl Display for ConcurrencyConfig
Source§impl From<&str> for ConcurrencyConfig
Custom value parser for clap (accepts “auto” or number)
impl From<&str> for ConcurrencyConfig
Custom value parser for clap (accepts “auto” or number)
Source§impl FromStr for ConcurrencyConfig
impl FromStr for ConcurrencyConfig
Source§impl ValueParserFactory for ConcurrencyConfig
impl ValueParserFactory for ConcurrencyConfig
Source§type Parser = ConcurrencyValueParser
type Parser = ConcurrencyValueParser
Generated parser, usually
ValueParser. Read moreSource§fn value_parser() -> Self::Parser
fn value_parser() -> Self::Parser
Create the specified
Self::ParserAuto Trait Implementations§
impl Freeze for ConcurrencyConfig
impl RefUnwindSafe for ConcurrencyConfig
impl Send for ConcurrencyConfig
impl Sync for ConcurrencyConfig
impl Unpin for ConcurrencyConfig
impl UnsafeUnpin for ConcurrencyConfig
impl UnwindSafe for ConcurrencyConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.