mod agent;
mod client;
mod content;
#[cfg(feature = "unstable_elicitation")]
mod elicitation;
mod error;
mod ext;
mod maybe_undefined;
#[cfg(feature = "unstable_nes")]
mod nes;
mod plan;
#[cfg(feature = "unstable_cancel_request")]
mod protocol_level;
mod rpc;
mod tool_call;
mod version;
pub use agent::*;
pub use client::*;
pub use content::*;
use derive_more::{Display, From};
#[cfg(feature = "unstable_elicitation")]
pub use elicitation::*;
pub use error::*;
pub use ext::*;
pub use maybe_undefined::*;
#[cfg(feature = "unstable_nes")]
pub use nes::*;
pub use plan::*;
#[cfg(feature = "unstable_cancel_request")]
pub use protocol_level::*;
pub use rpc::*;
pub use serde_json::value::RawValue;
pub use tool_call::*;
pub use version::*;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::{
borrow::Cow,
ffi::OsStr,
path::{Path, PathBuf},
sync::Arc,
};
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Hash, Display, From)]
#[serde(transparent)]
#[from(Arc<str>, String, &'static str)]
#[non_exhaustive]
pub struct SessionId(pub Arc<str>);
impl SessionId {
#[must_use]
pub fn new(id: impl Into<Arc<str>>) -> Self {
Self(id.into())
}
}
pub trait IntoOption<T> {
fn into_option(self) -> Option<T>;
}
impl<T> IntoOption<T> for Option<T> {
fn into_option(self) -> Option<T> {
self
}
}
impl<T> IntoOption<T> for T {
fn into_option(self) -> Option<T> {
Some(self)
}
}
impl IntoOption<String> for &str {
fn into_option(self) -> Option<String> {
Some(self.into())
}
}
impl IntoOption<String> for &mut str {
fn into_option(self) -> Option<String> {
Some(self.into())
}
}
impl IntoOption<String> for &String {
fn into_option(self) -> Option<String> {
Some(self.into())
}
}
impl IntoOption<String> for Box<str> {
fn into_option(self) -> Option<String> {
Some(self.into())
}
}
impl IntoOption<String> for Cow<'_, str> {
fn into_option(self) -> Option<String> {
Some(self.into())
}
}
impl IntoOption<String> for Arc<str> {
fn into_option(self) -> Option<String> {
Some(self.to_string())
}
}
impl<T: ?Sized + AsRef<OsStr>> IntoOption<PathBuf> for &T {
fn into_option(self) -> Option<PathBuf> {
Some(self.into())
}
}
impl IntoOption<PathBuf> for Box<Path> {
fn into_option(self) -> Option<PathBuf> {
Some(self.into())
}
}
impl IntoOption<PathBuf> for Cow<'_, Path> {
fn into_option(self) -> Option<PathBuf> {
Some(self.into())
}
}
impl IntoOption<serde_json::Value> for &str {
fn into_option(self) -> Option<serde_json::Value> {
Some(self.into())
}
}
impl IntoOption<serde_json::Value> for String {
fn into_option(self) -> Option<serde_json::Value> {
Some(self.into())
}
}
impl IntoOption<serde_json::Value> for Cow<'_, str> {
fn into_option(self) -> Option<serde_json::Value> {
Some(self.into())
}
}