Skip to content

Commit d600465

Browse files
committed
Module clean up
1 parent e780262 commit d600465

5 files changed

Lines changed: 336 additions & 340 deletions

File tree

src/agent.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6016,26 +6016,6 @@ mod test_serialization {
60166016
assert!(!json.as_object().unwrap().contains_key("headers"));
60176017
}
60186018

6019-
#[cfg(feature = "unstable_llm_providers")]
6020-
#[test]
6021-
fn test_set_providers_request_debug_redacts_headers() {
6022-
use std::collections::HashMap;
6023-
6024-
let mut headers = HashMap::new();
6025-
headers.insert(
6026-
"Authorization".to_string(),
6027-
"Bearer sk-secret-key".to_string(),
6028-
);
6029-
6030-
let request =
6031-
SetProvidersRequest::new("main", LlmProtocol::Anthropic, "https://api.anthropic.com")
6032-
.headers(headers);
6033-
6034-
let debug = format!("{request:?}");
6035-
assert!(debug.contains("[REDACTED]"));
6036-
assert!(!debug.contains("sk-secret-key"));
6037-
}
6038-
60396019
#[cfg(feature = "unstable_llm_providers")]
60406020
#[test]
60416021
fn test_disable_providers_request_serialization() {

src/lib.rs

Lines changed: 3 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ mod content;
5757
mod elicitation;
5858
mod error;
5959
mod ext;
60-
mod maybe_undefined;
6160
#[cfg(feature = "unstable_nes")]
6261
mod nes;
63-
#[cfg(feature = "unstable_llm_providers")]
64-
mod nullable;
6562
mod plan;
6663
#[cfg(feature = "unstable_cancel_request")]
6764
mod protocol_level;
6865
mod rpc;
66+
mod serde_util;
6967
mod tool_call;
7068
mod version;
7169

@@ -77,27 +75,20 @@ use derive_more::{Display, From};
7775
pub use elicitation::*;
7876
pub use error::*;
7977
pub use ext::*;
80-
pub use maybe_undefined::*;
8178
#[cfg(feature = "unstable_nes")]
8279
pub use nes::*;
83-
#[cfg(feature = "unstable_llm_providers")]
84-
pub use nullable::*;
8580
pub use plan::*;
8681
#[cfg(feature = "unstable_cancel_request")]
8782
pub use protocol_level::*;
8883
pub use rpc::*;
8984
pub use serde_json::value::RawValue;
85+
pub use serde_util::*;
9086
pub use tool_call::*;
9187
pub use version::*;
9288

9389
use schemars::JsonSchema;
9490
use serde::{Deserialize, Serialize};
95-
use std::{
96-
borrow::Cow,
97-
ffi::OsStr,
98-
path::{Path, PathBuf},
99-
sync::Arc,
100-
};
91+
use std::sync::Arc;
10192

10293
/// A unique identifier for a conversation session between a client and agent.
10394
///
@@ -117,100 +108,3 @@ impl SessionId {
117108
Self(id.into())
118109
}
119110
}
120-
121-
/// Utility trait for builder methods for optional values.
122-
/// This allows the caller to either pass in the value itself without wrapping it in `Some`,
123-
/// or to just pass in an Option if that is what they have.
124-
pub trait IntoOption<T> {
125-
fn into_option(self) -> Option<T>;
126-
}
127-
128-
impl<T> IntoOption<T> for Option<T> {
129-
fn into_option(self) -> Option<T> {
130-
self
131-
}
132-
}
133-
134-
impl<T> IntoOption<T> for T {
135-
fn into_option(self) -> Option<T> {
136-
Some(self)
137-
}
138-
}
139-
140-
impl IntoOption<String> for &str {
141-
fn into_option(self) -> Option<String> {
142-
Some(self.into())
143-
}
144-
}
145-
146-
impl IntoOption<String> for &mut str {
147-
fn into_option(self) -> Option<String> {
148-
Some(self.into())
149-
}
150-
}
151-
152-
impl IntoOption<String> for &String {
153-
fn into_option(self) -> Option<String> {
154-
Some(self.into())
155-
}
156-
}
157-
158-
impl IntoOption<String> for Box<str> {
159-
fn into_option(self) -> Option<String> {
160-
Some(self.into())
161-
}
162-
}
163-
164-
impl IntoOption<String> for Cow<'_, str> {
165-
fn into_option(self) -> Option<String> {
166-
Some(self.into())
167-
}
168-
}
169-
170-
impl IntoOption<String> for Arc<str> {
171-
fn into_option(self) -> Option<String> {
172-
Some(self.to_string())
173-
}
174-
}
175-
176-
impl<T: ?Sized + AsRef<OsStr>> IntoOption<PathBuf> for &T {
177-
fn into_option(self) -> Option<PathBuf> {
178-
Some(self.into())
179-
}
180-
}
181-
182-
impl IntoOption<PathBuf> for Box<Path> {
183-
fn into_option(self) -> Option<PathBuf> {
184-
Some(self.into())
185-
}
186-
}
187-
188-
impl IntoOption<PathBuf> for Cow<'_, Path> {
189-
fn into_option(self) -> Option<PathBuf> {
190-
Some(self.into())
191-
}
192-
}
193-
194-
impl IntoOption<ToolCallId> for &str {
195-
fn into_option(self) -> Option<ToolCallId> {
196-
Some(ToolCallId::new(self))
197-
}
198-
}
199-
200-
impl IntoOption<serde_json::Value> for &str {
201-
fn into_option(self) -> Option<serde_json::Value> {
202-
Some(self.into())
203-
}
204-
}
205-
206-
impl IntoOption<serde_json::Value> for String {
207-
fn into_option(self) -> Option<serde_json::Value> {
208-
Some(self.into())
209-
}
210-
}
211-
212-
impl IntoOption<serde_json::Value> for Cow<'_, str> {
213-
fn into_option(self) -> Option<serde_json::Value> {
214-
Some(self.into())
215-
}
216-
}

src/nullable.rs

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)