Skip to main content

SessionConfigBuilder

Struct SessionConfigBuilder 

Source
pub struct SessionConfigBuilder { /* private fields */ }
Expand description

Builder for SessionConfig with fluent API

Implementations§

Source§

impl SessionConfigBuilder

Source

pub fn new(query: impl Into<String>) -> Self

Source

pub fn resume_session_id(self, id: impl Into<String>) -> Self

Resume a specific session by ID (maps to –resume)

Source

pub fn explicit_session_id(self, id: impl Into<String>) -> Self

Use a specific session ID (maps to –session-id)

Source

pub fn continue_last_session(self, yes: bool) -> Self

Continue the last session (maps to –continue)

Source

pub fn fork_session(self, yes: bool) -> Self

Fork an existing session (maps to –fork-session)

Source

pub fn model(self, model: Model) -> Self

Set the primary model

Source

pub fn fallback_model(self, model: Model) -> Self

Set the fallback model (maps to –fallback-model)

Source

pub fn output_format(self, format: OutputFormat) -> Self

Set the output format

Source

pub fn input_format(self, format: InputFormat) -> Self

Set the input format (maps to –input-format)

Source

pub fn mcp_config(self, config: MCPConfig) -> Self

Set MCP server configuration

Source

pub fn strict_mcp_config(self, yes: bool) -> Self

Enable strict MCP config validation (maps to –strict-mcp-config)

Source

pub fn permission_mode(self, mode: PermissionMode) -> Self

Set permission mode (maps to –permission-mode)

Source

pub fn enable_dangerous_permissions(self) -> Self

Enable dangerous permission skipping. This sets both –allow-dangerously-skip-permissions and –dangerously-skip-permissions. Use with extreme caution.

Source

pub fn system_prompt(self, prompt: impl Into<String>) -> Self

Set system prompt override (maps to –system-prompt)

Source

pub fn append_system_prompt(self, prompt: impl Into<String>) -> Self

Append to system prompt (maps to –append-system-prompt)

Source

pub fn tools(self, tools: Vec<String>) -> Self

Set specific tools to enable (maps to –tools)

Source

pub fn allowed_tools(self, tools: Vec<String>) -> Self

Set allowed tools (maps to –allowedTools)

Source

pub fn disallowed_tools(self, tools: Vec<String>) -> Self

Set disallowed tools (maps to –disallowedTools)

Source

pub fn allow_tool(self, tool: impl Into<String>) -> Self

Add a single tool to allowed list

Source

pub fn disallow_tool(self, tool: impl Into<String>) -> Self

Add a single tool to disallowed list

Source

pub fn json_schema(self, schema: impl Into<String>) -> Self

Set JSON schema for structured output (maps to –json-schema)

Source

pub fn include_partial_messages(self, yes: bool) -> Self

Include partial messages in stream (maps to –include-partial-messages)

Source

pub fn replay_user_messages(self, yes: bool) -> Self

Replay user messages (maps to –replay-user-messages)

Source

pub fn settings(self, s: impl Into<String>) -> Self

Set settings JSON (maps to –settings)

Source

pub fn setting_sources(self, sources: Vec<String>) -> Self

Set setting sources (maps to –setting-sources)

Source

pub fn add_dir(self, dir: impl Into<PathBuf>) -> Self

Add a directory to context (maps to –add-dir, repeatable)

Source

pub fn plugin_dir(self, dir: impl Into<PathBuf>) -> Self

Add a plugin directory (maps to –plugin-dir, repeatable)

Source

pub fn ide(self, yes: bool) -> Self

Enable IDE mode (maps to –ide)

Source

pub fn agents(self, json: impl Into<String>) -> Self

Set agents configuration JSON (maps to –agents)

Source

pub fn debug(self, yes: bool) -> Self

Enable debug mode (maps to –debug)

Source

pub fn debug_filter(self, filter: impl Into<String>) -> Self

Set debug filter pattern

Source

pub fn working_dir(self, dir: impl Into<PathBuf>) -> Self

Set working directory for the Claude process

Source

pub fn env(self, env: HashMap<String, String>) -> Self

Set environment variables to inject into the Claude process

Source

pub fn env_var(self, key: impl Into<String>, val: impl Into<String>) -> Self

Add a single environment variable

Source

pub fn verbose(self, verbose: bool) -> Self

Enable verbose output

Source

pub fn build(self) -> Result<SessionConfig>

Build the SessionConfig, validating all settings

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more