pub struct Query { /* private fields */ }Expand description
Internal query handler with control protocol support
Implementations§
Source§impl Query
impl Query
Sourcepub fn new(
transport: Arc<Mutex<Box<dyn Transport + Send>>>,
is_streaming_mode: bool,
can_use_tool: Option<Arc<dyn CanUseTool>>,
hooks: Option<HashMap<String, Vec<HookMatcher>>>,
sdk_mcp_servers: HashMap<String, Arc<dyn Any + Send + Sync>>,
) -> Self
pub fn new( transport: Arc<Mutex<Box<dyn Transport + Send>>>, is_streaming_mode: bool, can_use_tool: Option<Arc<dyn CanUseTool>>, hooks: Option<HashMap<String, Vec<HookMatcher>>>, sdk_mcp_servers: HashMap<String, Arc<dyn Any + Send + Sync>>, ) -> Self
Create a new Query handler
Sourcepub async fn register_hook_callback_for_test(
&self,
callback_id: String,
callback: Arc<dyn HookCallback>,
)
pub async fn register_hook_callback_for_test( &self, callback_id: String, callback: Arc<dyn HookCallback>, )
Test helper to register a hook callback with a known ID
This is intended for E2E tests to inject a callback ID that can be
referenced by inbound hook_callback control messages.
Sourcepub async fn initialize(&mut self) -> Result<()>
pub async fn initialize(&mut self) -> Result<()>
Initialize the control protocol
Sourcepub async fn stream_input<S>(&mut self, input_stream: S) -> Result<()>
pub async fn stream_input<S>(&mut self, input_stream: S) -> Result<()>
Stream input messages to the CLI stdin by converting JSON values to InputMessage
Sourcepub async fn receive_messages(&mut self) -> Receiver<Result<Message>>
pub async fn receive_messages(&mut self) -> Receiver<Result<Message>>
Receive messages
Sourcepub async fn set_permission_mode(&mut self, mode: &str) -> Result<()>
pub async fn set_permission_mode(&mut self, mode: &str) -> Result<()>
Set permission mode via control protocol
Sourcepub async fn set_model(&mut self, model: Option<String>) -> Result<()>
pub async fn set_model(&mut self, model: Option<String>) -> Result<()>
Set the active model via control protocol
Sourcepub fn get_initialization_result(&self) -> Option<&JsonValue>
pub fn get_initialization_result(&self) -> Option<&JsonValue>
Get initialization result
Auto Trait Implementations§
impl Freeze for Query
impl !RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl !UnwindSafe for Query
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> 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 more