pub struct XetContext {
pub runtime: Arc<XetRuntime>,
pub config: Arc<XetConfig>,
pub common: Arc<XetCommon>,
}Expand description
Bundles the thread pool, configuration, and shared state into a single clonable handle.
Every major struct in the codebase should accept &XetContext in its constructor
and store a clone. This replaces the thread-local globals, allowing multiple
independent runtimes within the same process.
Fields§
§runtime: Arc<XetRuntime>§config: Arc<XetConfig>§common: Arc<XetCommon>Implementations§
Source§impl XetContext
impl XetContext
Sourcepub fn new(config: XetConfig, runtime: Arc<XetRuntime>) -> Self
pub fn new(config: XetConfig, runtime: Arc<XetRuntime>) -> Self
Creates a context from a pre-built thread pool and configuration.
Sourcepub fn default() -> Result<Self, RuntimeError>
pub fn default() -> Result<Self, RuntimeError>
Creates a context with default configuration and an auto-detected thread pool.
If called from an owned runtime worker thread, reuses that owned XetRuntime.
Otherwise, if called from within an existing tokio runtime, wraps that runtime.
If neither is available, spins up a new owned tokio thread pool.
Sourcepub fn with_config(config: XetConfig) -> Result<Self, RuntimeError>
pub fn with_config(config: XetConfig) -> Result<Self, RuntimeError>
Creates a context with the given configuration and an auto-detected thread pool.
Follows the same runtime selection as default:
reuse an owned runtime if available, wrap an existing tokio handle, or create a new one.
Sourcepub fn from_external(rt_handle: TokioRuntimeHandle, config: XetConfig) -> Self
pub fn from_external(rt_handle: TokioRuntimeHandle, config: XetConfig) -> Self
Wraps a caller-provided tokio handle with the given configuration.
Sourcepub fn handle_meets_requirements(handle: &TokioRuntimeHandle) -> bool
pub fn handle_meets_requirements(handle: &TokioRuntimeHandle) -> bool
Checks whether a tokio handle meets the requirements for use with xet.
Sourcepub fn check_sigint_shutdown(&self) -> Result<(), RuntimeError>
pub fn check_sigint_shutdown(&self) -> Result<(), RuntimeError>
Returns an error if the runtime is in the middle of a SIGINT shutdown.
Trait Implementations§
Source§impl Clone for XetContext
impl Clone for XetContext
Source§fn clone(&self) -> XetContext
fn clone(&self) -> XetContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more