repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_core/src/epoch.rs
memo_core/src/epoch.rs
use crate::btree::{self, SeekBias}; use crate::buffer::{self, Buffer, Point, Selection, SelectionSetId, Text}; use crate::operation_queue::{self, OperationQueue}; use crate::serialization; use crate::time; use crate::Error; use crate::Oid; use crate::ReplicaId; use flatbuffers::{FlatBufferBuilder, UnionWIPOffset, WIPOf...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
true
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_core/src/operation_queue.rs
memo_core/src/operation_queue.rs
use crate::btree::{Cursor, Dimension, Edit, Item, KeyedItem, Tree}; use crate::time; use std::fmt::Debug; use std::ops::{Add, AddAssign}; pub trait Operation: Clone + Debug + Eq { fn timestamp(&self) -> time::Lamport; } #[derive(Clone, Debug)] pub struct OperationQueue<T: Operation>(Tree<T>); #[derive(Clone, Cop...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_core/src/buffer.rs
memo_core/src/buffer.rs
use crate::btree::{self, SeekBias}; use crate::operation_queue::{self, OperationQueue}; use crate::serialization; use crate::time; use crate::{Error, ReplicaId}; use flatbuffers::{FlatBufferBuilder, WIPOffset}; use lazy_static::lazy_static; use serde_derive::{Deserialize, Serialize}; use smallvec::SmallVec; use std::ce...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
true
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_core/src/work_tree.rs
memo_core/src/work_tree.rs
use crate::buffer::{self, Change, Point, Text}; use crate::epoch::{self, Cursor, DirEntry, Epoch, FileId, FileType}; use crate::serialization; use crate::{time, Error, Oid, ReplicaId}; use flatbuffers::{FlatBufferBuilder, WIPOffset}; use futures::{future, stream, Async, Future, Poll, Stream}; use serde_derive::{Deseria...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
true
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_core/src/serialization/mod.rs
memo_core/src/serialization/mod.rs
mod schema_generated; pub use self::schema_generated::*;
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_core/src/serialization/schema_generated.rs
memo_core/src/serialization/schema_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify #![allow(dead_code)] #![allow(unused_imports)] extern crate flatbuffers; // struct ReplicaId, aligned to 8 #[repr(C, align(8))] #[derive(Clone, Copy, Debug, PartialEq)] pub struct ReplicaId { first_8_bytes_: u64, last_8_bytes_: u64, } // pub s...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
true
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/app.rs
xray_core/src/app.rs
use bytes::Bytes; use fs; use futures::unsync::mpsc::{self, UnboundedReceiver, UnboundedSender}; use futures::{future, Async, Future, IntoFuture, Stream}; use never::Never; use notify_cell::{NotifyCell, NotifyCellObserver}; use project::LocalProject; use rpc::{self, client, server}; use serde_json; use std::cell::RefCe...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/workspace.rs
xray_core/src/workspace.rs
use buffer::{self, Buffer, BufferId}; use buffer_view::{BufferView, BufferViewDelegate}; use cross_platform; use file_finder::{FileFinderView, FileFinderViewDelegate}; use futures::{Future, Poll, Stream}; use never::Never; use notify_cell::NotifyCell; use notify_cell::NotifyCellObserver; use project::{ self, LocalP...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/lib.rs
xray_core/src/lib.rs
#![feature(unsize, coerce_unsized)] extern crate bincode; extern crate bytes; #[macro_use] extern crate lazy_static; extern crate futures; extern crate parking_lot; extern crate seahash; extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; extern crate smallvec; #[cfg(test)...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/never.rs
xray_core/src/never.rs
#[derive(Debug, Serialize, Deserialize)] pub enum Never {}
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/fs.rs
xray_core/src/fs.rs
use buffer::BufferSnapshot; use cross_platform; use futures::{Async, Future, Stream}; use notify_cell::NotifyCell; use parking_lot::RwLock; use rpc::{client, server}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg(test)] use serde_json; use std::cell::RefCell; use std::io; use std::iter::Iterator;...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/stream_ext.rs
xray_core/src/stream_ext.rs
use futures::{Future, Poll, Stream}; use std::fmt::Debug; use std::time; use tokio_core::reactor; use tokio_timer::Interval; pub trait StreamExt where Self: Stream + Sized, { fn wait_next(&mut self, reactor: &mut reactor::Core) -> Option<Self::Item> where Self::Item: Debug, Self::Error: Deb...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/buffer_view.rs
xray_core/src/buffer_view.rs
use buffer::{self, Buffer, BufferId, Point, Selection, SelectionSetId}; use futures::{Future, Poll, Stream}; use movement; use notify_cell::NotifyCell; use serde_json; use std::cell::{Cell, Ref, RefCell}; use std::cmp::{self, Ordering}; use std::ops::Range; use std::rc::Rc; use window::{View, WeakViewHandle, Window}; u...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
true
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/notify_cell.rs
xray_core/src/notify_cell.rs
use std::sync::{Arc, Weak}; use futures::{Async, Poll, Stream}; use futures::task::{self, Task}; use parking_lot::RwLock; type Version = usize; #[derive(Debug, Eq, PartialEq)] pub enum TrySetError { ObserverDisconnected } #[derive(Clone, Debug)] pub struct NotifyCell<T: Clone> { observer: Option<NotifyCellOb...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/wasm_logging.rs
xray_core/src/wasm_logging.rs
use wasm_bindgen::prelude::*; #[wasm_bindgen(js_namespace = console)] extern "C" { pub fn log(s: &str); pub fn error(s: &str); } #[macro_export] macro_rules! println { ($($arg:tt)*) => ($crate::wasm_logging::log(&::std::fmt::format(format_args!($($arg)*)))); } #[macro_export] macro_rules! eprintln { ...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/tree.rs
xray_core/src/tree.rs
use std::clone::Clone; use std::fmt; use std::ops::{Add, AddAssign, Range}; use std::sync::Arc; const MIN_CHILDREN: usize = 2; const MAX_CHILDREN: usize = 4; pub trait Item: Clone + Eq + fmt::Debug { type Summary: for<'a> AddAssign<&'a Self::Summary> + Default + Eq + Clone + fmt::Debug; fn summarize(&self) -...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/cross_platform.rs
xray_core/src/cross_platform.rs
use std::borrow::Cow; #[cfg(unix)] use std::ffi::{OsStr, OsString}; #[cfg(unix)] use std::path::PathBuf; pub const UNIX_MAIN_SEPARATOR: u8 = b'/'; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)] pub enum PathComponent { Unix(Vec<u8>), } #[derive(Clone, Debug, Eq, PartialEq, Serial...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/window.rs
xray_core/src/window.rs
use futures::task::{self, Task}; use futures::{Async, Future, Poll, Stream}; use serde_json; use std::boxed::Box; use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::marker::Unsize; use std::ops::CoerceUnsized; use std::rc::{Rc, Weak}; use BackgroundExecutor; pub type ViewId = usize; pub trait ...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/project.rs
xray_core/src/project.rs
use buffer::{self, Buffer, BufferId}; use cross_platform; use fs; use futures::{future, Async, Future, Poll}; use fuzzy; use never::Never; use notify_cell::{NotifyCell, NotifyCellObserver, WeakNotifyCell}; use rpc; use std::cell::{Cell, RefCell}; use std::cmp; use std::collections::{BinaryHeap, HashMap}; use std::error...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/file_finder.rs
xray_core/src/file_finder.rs
use cross_platform; use futures::{Async, Poll, Stream}; use notify_cell::{NotifyCell, NotifyCellObserver}; use project::{PathSearch, PathSearchResult, PathSearchStatus, TreeId}; use serde_json; use window::{View, WeakViewHandle, Window}; pub trait FileFinderViewDelegate { fn search_paths( &self, ne...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/buffer.rs
xray_core/src/buffer.rs
use super::rpc::{client, Error as RpcError}; use super::tree::{self, SeekBias, Tree}; use fs; use futures::{unsync, Future, Stream}; use notify_cell::{NotifyCell, NotifyCellObserver}; use seahash::SeaHasher; use serde::{self, Deserialize, Deserializer, Serialize, Serializer}; use std::cell::RefCell; use std::cmp::{self...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
true
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/movement.rs
xray_core/src/movement.rs
use buffer::{Buffer, Point}; use std::char::decode_utf16; use std::cmp; pub fn left(buffer: &Buffer, mut point: Point) -> Point { if point.column > 0 { point.column -= 1; } else if point.row > 0 { point.row -= 1; point.column = buffer.len_for_row(point.row).unwrap(); } point } ...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/fuzzy.rs
xray_core/src/fuzzy.rs
use std::f64; use std::fmt; use std::ops::{Index, IndexMut}; pub type Score = f64; pub const SCORE_MIN: Score = f64::NEG_INFINITY; const SCORE_GAP_LEADING: Score = -0.005; const SCORE_GAP_TRAILING: Score = -0.005; const SCORE_GAP_INNER: Score = -0.01; const SCORE_MATCH_CONSECUTIVE: Score = 1.0; const SCORE_MATCH_SLAS...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/rpc/messages.rs
xray_core/src/rpc/messages.rs
use super::Error; use bytes::Bytes; use std::collections::{HashMap, HashSet}; pub type RequestId = usize; pub type ServiceId = usize; #[derive(Serialize, Deserialize)] pub enum MessageToClient { Update { insertions: HashMap<ServiceId, Bytes>, updates: HashMap<ServiceId, Vec<Bytes>>, remova...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/rpc/client.rs
xray_core/src/rpc/client.rs
use super::messages::{MessageToClient, MessageToServer, RequestId, Response, ServiceId}; use super::{server, Error}; use bincode::{deserialize, serialize}; use bytes::Bytes; use futures::{self, future, stream, unsync, Async, Future, Poll, Stream}; use serde::{Deserialize, Serialize}; use std::cell::{Ref, RefCell}; use ...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/rpc/mod.rs
xray_core/src/rpc/mod.rs
pub mod client; mod messages; pub mod server; pub use self::messages::{Response, ServiceId}; use std::error; use std::fmt; #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub enum Error { ConnectionDropped, IoError(String), ServiceDropped, ServiceNotFound, ServiceTaken, UpdatesT...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/src/rpc/server.rs
xray_core/src/rpc/server.rs
use super::messages::{MessageToClient, MessageToServer, RequestId, Response, ServiceId}; use super::Error; use bincode::{deserialize, serialize}; use bytes::Bytes; use futures::stream::FuturesUnordered; use futures::task::{self, Task}; use futures::{future, Async, Future, Poll, Stream}; use never::Never; use serde::{De...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_core/benches/bench.rs
xray_core/benches/bench.rs
extern crate xray_core; #[macro_use] extern crate criterion; use criterion::Criterion; use std::cell::RefCell; use std::rc::Rc; use xray_core::buffer::{Buffer, Point}; use xray_core::buffer_view::BufferView; fn add_selection(c: &mut Criterion) { c.bench_function("add_selection_below", |b| { b.iter_with_se...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/memo_js/src/lib.rs
memo_js/src/lib.rs
#![feature(macros_in_extern)] use bincode; use futures::{Async, Future, Poll, Stream}; use memo_core as memo; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_derive::{Deserialize, Serialize}; use std::cell::Cell; use std::collections::{HashMap, HashSet}; use std::io; use std::marker::PhantomDa...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_wasm/src/lib.rs
xray_wasm/src/lib.rs
extern crate bytes; extern crate futures; extern crate wasm_bindgen; #[macro_use] extern crate xray_core; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; use bytes::Bytes; use futures::executor::{self, Notify, Spawn}; use futures::unsync::mpsc; use futures::{future, stream}; use fu...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_server/src/messages.rs
xray_server/src/messages.rs
use serde_json; use std::net::SocketAddr; use std::path::PathBuf; use xray_core::{ViewId, WindowId, WindowUpdate}; #[derive(Deserialize, Debug)] #[serde(tag = "type")] pub enum IncomingMessage { StartApp, StartCli { headless: bool, }, TcpListen { port: u16, }, StartWindow { ...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_server/src/json_lines_codec.rs
xray_server/src/json_lines_codec.rs
use std::io; use bytes::BytesMut; use serde::{Deserialize, Serialize}; use serde_json; use tokio_io::codec::{Decoder, Encoder}; use std::marker::PhantomData; pub struct JsonLinesCodec<In, Out> { phantom1: PhantomData<In>, phantom2: PhantomData<Out>, } impl<In, Out> JsonLinesCodec<In, Out> where In: for<'a...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_server/src/fs.rs
xray_server/src/fs.rs
use futures::{self, Future, Stream}; use ignore::WalkBuilder; use parking_lot::Mutex; use std::char::decode_utf16; use std::ffi::OsString; use std::fs; use std::io::{self, Read, Seek, SeekFrom, Write}; use std::os::unix::fs::MetadataExt; use std::path::PathBuf; use std::sync::Arc; use std::thread; use xray_core::buffer...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_server/src/server.rs
xray_server/src/server.rs
use bytes::Bytes; use fs; use futures::{future, stream, Future, IntoFuture, Sink, Stream}; use futures_cpupool::CpuPool; use messages::{IncomingMessage, OutgoingMessage}; use std::cell::RefCell; use std::error::Error; use std::io; use std::net::SocketAddr; use std::path::PathBuf; use std::rc::Rc; use tokio_core::net::{...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
atom-archive/xray
https://github.com/atom-archive/xray/blob/cb6c5809f18c733f55b89ce202678c379a4cfc7b/xray_server/src/main.rs
xray_server/src/main.rs
mod messages; mod server; mod fs; mod json_lines_codec; extern crate bytes; extern crate futures; extern crate futures_cpupool; extern crate ignore; extern crate parking_lot; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate tokio_core; extern crate tokio_io; extern crat...
rust
MIT
cb6c5809f18c733f55b89ce202678c379a4cfc7b
2026-01-04T15:47:27.093190Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/build.rs
src-tauri/build.rs
fn main() { tauri_build::build() }
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/prompt_files.rs
src-tauri/src/prompt_files.rs
use std::path::PathBuf; use crate::app_config::AppType; use crate::codex_config::get_codex_auth_path; use crate::config::get_claude_settings_path; use crate::error::AppError; use crate::gemini_config::get_gemini_dir; /// 返回指定应用所使用的提示词文件路径。 pub fn prompt_file_path(app: &AppType) -> Result<PathBuf, AppError> { let ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/config.rs
src-tauri/src/config.rs
use serde::{Deserialize, Serialize}; use std::fs; use std::io::Write; use std::path::{Path, PathBuf}; use crate::error::AppError; /// 获取 Claude Code 配置目录路径 pub fn get_claude_config_dir() -> PathBuf { if let Some(custom) = crate::settings::get_claude_override_dir() { return custom; } dirs::home_di...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/settings.rs
src-tauri/src/settings.rs
use serde::{Deserialize, Serialize}; use std::fs; use std::path::PathBuf; use std::sync::{OnceLock, RwLock}; use crate::app_config::AppType; use crate::error::AppError; /// 自定义端点配置(历史兼容,实际存储在 provider.meta.custom_endpoints) #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/lib.rs
src-tauri/src/lib.rs
mod app_config; mod app_store; mod auto_launch; mod claude_mcp; mod claude_plugin; mod codex_config; mod commands; mod config; mod database; mod deeplink; mod error; mod gemini_config; mod gemini_mcp; mod init_status; mod mcp; mod prompt; mod prompt_files; mod provider; mod provider_defaults; mod proxy; mod services; m...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
true
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/init_status.rs
src-tauri/src/init_status.rs
use serde::Serialize; use std::sync::{OnceLock, RwLock}; #[derive(Debug, Clone, Serialize)] pub struct InitErrorPayload { pub path: String, pub error: String, } static INIT_ERROR: OnceLock<RwLock<Option<InitErrorPayload>>> = OnceLock::new(); fn cell() -> &'static RwLock<Option<InitErrorPayload>> { INIT_E...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/store.rs
src-tauri/src/store.rs
use crate::database::Database; use crate::services::ProxyService; use std::sync::Arc; /// 全局应用状态 pub struct AppState { pub db: Arc<Database>, pub proxy_service: ProxyService, } impl AppState { /// 创建新的应用状态 pub fn new(db: Arc<Database>) -> Self { let proxy_service = ProxyService::new(db.clone()...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/tray.rs
src-tauri/src/tray.rs
//! 托盘菜单管理模块 //! //! 负责系统托盘图标和菜单的创建、更新和事件处理。 use tauri::menu::{CheckMenuItem, Menu, MenuBuilder, MenuItem}; use tauri::{Emitter, Manager}; use crate::app_config::AppType; use crate::error::AppError; use crate::store::AppState; /// 托盘菜单文本(国际化) #[derive(Clone, Copy)] pub struct TrayTexts { pub show_main: &'static ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/claude_plugin.rs
src-tauri/src/claude_plugin.rs
use std::fs; use std::path::PathBuf; use crate::error::AppError; const CLAUDE_DIR: &str = ".claude"; const CLAUDE_CONFIG_FILE: &str = "config.json"; fn claude_dir() -> Result<PathBuf, AppError> { // 优先使用设置中的覆盖目录 if let Some(dir) = crate::settings::get_claude_override_dir() { return Ok(dir); } ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/error.rs
src-tauri/src/error.rs
use std::path::Path; use std::sync::PoisonError; use thiserror::Error; #[derive(Debug, Error)] pub enum AppError { #[error("配置错误: {0}")] Config(String), #[error("无效输入: {0}")] InvalidInput(String), #[error("IO 错误: {path}: {source}")] Io { path: String, #[source] source: ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/gemini_mcp.rs
src-tauri/src/gemini_mcp.rs
use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use std::fs; use std::path::{Path, PathBuf}; use crate::config::atomic_write; use crate::error::AppError; use crate::gemini_config::get_gemini_settings_path; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/prompt.rs
src-tauri/src/prompt.rs
use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Prompt { pub id: String, pub name: String, pub content: String, #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, #[serde(default)] pub enabled: bool, #[serde...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/usage_script.rs
src-tauri/src/usage_script.rs
use reqwest::Client; use rquickjs::{Context, Function, Runtime}; use serde_json::Value; use std::collections::HashMap; use std::time::Duration; use url::{Host, Url}; use crate::error::AppError; /// 执行用量查询脚本 pub async fn execute_usage_script( script_code: &str, api_key: &str, base_url: &str, timeout_se...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/provider_defaults.rs
src-tauri/src/provider_defaults.rs
use once_cell::sync::Lazy; use std::collections::HashMap; /// 供应商图标信息 #[derive(Debug, Clone)] #[allow(dead_code)] pub struct ProviderIcon { pub name: &'static str, pub color: &'static str, } /// 供应商名称到图标的默认映射 #[allow(dead_code)] pub static DEFAULT_PROVIDER_ICONS: Lazy<HashMap<&'static str, ProviderIcon>> = La...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/main.rs
src-tauri/src/main.rs
// Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { // 在 Linux 上设置 WebKit 环境变量以解决 DMA-BUF 渲染问题 // 某些 Linux 系统(如 Debian 13.2、Nvidia GPU)上 WebKitGTK 的 DMA-BUF 渲染器可能导致白屏/黑屏 // 参考: https://github.com/tauri-a...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/claude_mcp.rs
src-tauri/src/claude_mcp.rs
use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use std::env; use std::fs; use std::path::{Path, PathBuf}; use crate::config::{atomic_write, get_claude_mcp_path, get_default_claude_mcp_path}; use crate::error::AppError; /// 需要在 Windows 上用 cmd /c 包装的命令 /// 这些命令在 Windows 上实际是 .cmd 批处理文件,需要通过 cmd /c 来...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/auto_launch.rs
src-tauri/src/auto_launch.rs
use crate::error::AppError; use auto_launch::{AutoLaunch, AutoLaunchBuilder}; /// 获取 macOS 上的 .app bundle 路径 /// 将 `/path/to/CC Switch.app/Contents/MacOS/CC Switch` 转换为 `/path/to/CC Switch.app` #[cfg(target_os = "macos")] fn get_macos_app_bundle_path(exe_path: &std::path::Path) -> Option<std::path::PathBuf> { let ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/app_config.rs
src-tauri/src/app_config.rs
use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::str::FromStr; use crate::services::skill::SkillStore; /// MCP 服务器应用状态(标记应用到哪些客户端) #[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)] pub struct McpApps { #[serde(default)] pub claude: bool, #[serde(default)] ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
true
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/app_store.rs
src-tauri/src/app_store.rs
use serde_json::Value; use std::path::PathBuf; use std::sync::{OnceLock, RwLock}; use tauri_plugin_store::StoreExt; use crate::error::AppError; /// Store 中的键名 const STORE_KEY_APP_CONFIG_DIR: &str = "app_config_dir_override"; /// 缓存当前的 app_config_dir 覆盖路径,避免存储 AppHandle static APP_CONFIG_DIR_OVERRIDE: OnceLock<RwLock...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/provider.rs
src-tauri/src/provider.rs
use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; // SSOT 模式:不再写供应商副本文件 /// 供应商结构体 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Provider { pub id: String, pub name: String, #[serde(rename = "settingsConfig")] pub settings_c...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/gemini_config.rs
src-tauri/src/gemini_config.rs
use crate::config::write_text_file; use crate::error::AppError; use serde_json::Value; use std::collections::HashMap; use std::fs; use std::path::PathBuf; /// 获取 Gemini 配置目录路径(支持设置覆盖) pub fn get_gemini_dir() -> PathBuf { if let Some(custom) = crate::settings::get_gemini_override_dir() { return custom; ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/codex_config.rs
src-tauri/src/codex_config.rs
// unused imports removed use std::path::PathBuf; use crate::config::{ atomic_write, delete_file, sanitize_provider_name, write_json_file, write_text_file, }; use crate::error::AppError; use serde_json::Value; use std::fs; use std::path::Path; /// 获取 Codex 配置目录路径 pub fn get_codex_config_dir() -> PathBuf { if ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/config.rs
src-tauri/src/services/config.rs
use super::provider::ProviderService; use crate::app_config::{AppType, MultiAppConfig}; use crate::error::AppError; use crate::provider::Provider; use chrono::Utc; use serde_json::Value; use std::fs; use std::path::Path; const MAX_BACKUPS: usize = 10; /// 配置导入导出相关业务逻辑 pub struct ConfigService; impl ConfigService { ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/env_checker.rs
src-tauri/src/services/env_checker.rs
use serde::{Deserialize, Serialize}; #[cfg(not(target_os = "windows"))] use std::fs; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct EnvConflict { pub var_name: String, pub var_value: String, pub source_type: String, // "system" | "file" pub source_path: St...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/mcp.rs
src-tauri/src/services/mcp.rs
use indexmap::IndexMap; use std::collections::HashMap; use crate::app_config::{AppType, McpServer}; use crate::error::AppError; use crate::mcp; use crate::store::AppState; /// MCP 相关业务逻辑(v3.7.0 统一结构) pub struct McpService; impl McpService { /// 获取所有 MCP 服务器(统一结构) pub fn get_all_servers(state: &AppState) -> R...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/stream_check.rs
src-tauri/src/services/stream_check.rs
//! 流式健康检查服务 //! //! 使用流式 API 进行快速健康检查,只需接收首个 chunk 即判定成功。 use futures::StreamExt; use regex::Regex; use reqwest::Client; use serde::{Deserialize, Serialize}; use serde_json::json; use std::time::{Duration, Instant}; use crate::app_config::AppType; use crate::error::AppError; use crate::provider::Provider; use crate:...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/speedtest.rs
src-tauri/src/services/speedtest.rs
use futures::future::join_all; use reqwest::{Client, Url}; use serde::Serialize; use std::time::{Duration, Instant}; use crate::error::AppError; const DEFAULT_TIMEOUT_SECS: u64 = 8; const MAX_TIMEOUT_SECS: u64 = 30; const MIN_TIMEOUT_SECS: u64 = 2; /// 端点测速结果 #[derive(Debug, Clone, Serialize)] pub struct EndpointLat...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/prompt.rs
src-tauri/src/services/prompt.rs
use indexmap::IndexMap; use crate::app_config::AppType; use crate::config::write_text_file; use crate::error::AppError; use crate::prompt::Prompt; use crate::prompt_files::prompt_file_path; use crate::store::AppState; /// 安全地获取当前 Unix 时间戳 fn get_unix_timestamp() -> Result<i64, AppError> { std::time::SystemTime::n...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/skill.rs
src-tauri/src/services/skill.rs
//! Skills 服务层 //! //! v3.10.0+ 统一管理架构: //! - SSOT(单一事实源):`~/.cc-switch/skills/` //! - 安装时下载到 SSOT,按需同步到各应用目录 //! - 数据库存储安装记录和启用状态 use anyhow::{anyhow, Context, Result}; use chrono::{DateTime, Utc}; use reqwest::Client; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::fs; use std...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
true
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/mod.rs
src-tauri/src/services/mod.rs
pub mod config; pub mod env_checker; pub mod env_manager; pub mod mcp; pub mod prompt; pub mod provider; pub mod proxy; pub mod skill; pub mod speedtest; pub mod stream_check; pub mod usage_stats; pub use config::ConfigService; pub use mcp::McpService; pub use prompt::PromptService; pub use provider::{ProviderService,...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/usage_stats.rs
src-tauri/src/services/usage_stats.rs
//! 使用统计服务 //! //! 提供使用量数据的聚合查询功能 use crate::database::{lock_conn, Database}; use crate::error::AppError; use chrono::{Local, TimeZone}; use rusqlite::{params, Connection, OptionalExtension}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; use std::str::FromStr; /// 使用量汇总 #[...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
true
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/env_manager.rs
src-tauri/src/services/env_manager.rs
use super::env_checker::EnvConflict; use chrono::Utc; use serde::{Deserialize, Serialize}; use std::fs; use std::path::PathBuf; #[cfg(target_os = "windows")] use winreg::enums::*; #[cfg(target_os = "windows")] use winreg::RegKey; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct B...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/proxy.rs
src-tauri/src/services/proxy.rs
//! 代理服务业务逻辑层 //! //! 提供代理服务器的启动、停止和配置管理 use crate::app_config::AppType; use crate::config::{get_claude_settings_path, read_json_file, write_json_file}; use crate::database::Database; use crate::provider::Provider; use crate::proxy::server::ProxyServer; use crate::proxy::types::*; use crate::services::provider::write_...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
true
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/provider/endpoints.rs
src-tauri/src/services/provider/endpoints.rs
//! Custom endpoints management //! //! Handles CRUD operations for provider custom endpoints. use std::time::{SystemTime, UNIX_EPOCH}; use crate::app_config::AppType; use crate::error::AppError; use crate::settings::CustomEndpoint; use crate::store::AppState; /// Get custom endpoints list for a provider pub fn get_...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/provider/live.rs
src-tauri/src/services/provider/live.rs
//! Live configuration operations //! //! Handles reading and writing live configuration files for Claude, Codex, and Gemini. use std::collections::HashMap; use serde_json::{json, Value}; use crate::app_config::AppType; use crate::codex_config::{get_codex_auth_path, get_codex_config_path}; use crate::config::{delete...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/provider/mod.rs
src-tauri/src/services/provider/mod.rs
//! Provider service module //! //! Handles provider CRUD operations, switching, and configuration management. mod endpoints; mod gemini_auth; mod live; mod usage; use indexmap::IndexMap; use regex::Regex; use serde::Deserialize; use serde_json::Value; use crate::app_config::AppType; use crate::error::AppError; use ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
true
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/provider/usage.rs
src-tauri/src/services/provider/usage.rs
//! Usage script execution //! //! Handles executing and formatting usage query results. use crate::app_config::AppType; use crate::error::AppError; use crate::provider::{UsageData, UsageResult, UsageScript}; use crate::settings; use crate::store::AppState; use crate::usage_script; /// Execute usage script and format...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/services/provider/gemini_auth.rs
src-tauri/src/services/provider/gemini_auth.rs
//! Gemini authentication type detection //! //! Detects whether a Gemini provider uses PackyCode API Key, Google OAuth, or generic API Key. use crate::error::AppError; use crate::provider::Provider; /// Gemini authentication type enumeration /// /// Used to optimize performance by avoiding repeated provider type det...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/error_mapper.rs
src-tauri/src/proxy/error_mapper.rs
//! 错误类型到 HTTP 状态码的映射 //! //! 将 ProxyError 映射到合适的 HTTP 状态码,用于日志记录 use super::ProxyError; /// 将 ProxyError 映射到 HTTP 状态码 /// /// 映射规则: /// - 上游错误:直接使用上游返回的状态码 /// - 超时:504 Gateway Timeout /// - 连接失败:502 Bad Gateway /// - 无可用 Provider:503 Service Unavailable /// - 重试耗尽:503 Service Unavailable /// - 其他错误:500 Internal Ser...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/response_processor.rs
src-tauri/src/proxy/response_processor.rs
//! 响应处理器模块 //! //! 统一处理流式和非流式 API 响应 use super::{ handler_config::UsageParserConfig, handler_context::{RequestContext, StreamingTimeoutConfig}, server::ProxyState, usage::parser::TokenUsage, ProxyError, }; use axum::response::Response; use bytes::Bytes; use futures::stream::{Stream, StreamExt}; us...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/handlers.rs
src-tauri/src/proxy/handlers.rs
//! 请求处理器 //! //! 处理各种API端点的HTTP请求 //! //! 重构后的结构: //! - 通用逻辑提取到 `handler_context` 和 `response_processor` 模块 //! - 各 handler 只保留独特的业务逻辑 //! - Claude 的格式转换逻辑保留在此文件(用于 OpenRouter 旧接口回退) use super::{ error_mapper::{get_error_message, map_proxy_error_to_status}, handler_config::{ CLAUDE_PARSER_CONFIG, CODE...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/provider_router.rs
src-tauri/src/proxy/provider_router.rs
//! 供应商路由器模块 //! //! 负责选择和管理代理目标供应商,实现智能故障转移 use crate::database::Database; use crate::error::AppError; use crate::provider::Provider; use crate::proxy::circuit_breaker::{AllowResult, CircuitBreaker, CircuitBreakerConfig}; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::RwLock; /// 供应商路由器 pub stru...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/model_mapper.rs
src-tauri/src/proxy/model_mapper.rs
//! 模型映射模块 //! //! 在请求转发前,根据 Provider 配置替换请求中的模型名称 use crate::provider::Provider; use serde_json::Value; /// 模型映射配置 pub struct ModelMapping { pub haiku_model: Option<String>, pub sonnet_model: Option<String>, pub opus_model: Option<String>, pub default_model: Option<String>, pub reasoning_model: O...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/session.rs
src-tauri/src/proxy/session.rs
//! Proxy Session - 请求会话管理 //! //! 为每个代理请求创建会话上下文,在整个请求生命周期中跟踪状态和元数据。 //! //! ## Session ID 提取 //! //! 支持从客户端请求中提取 Session ID,用于关联同一对话的多个请求: //! - Claude: 从 `metadata.user_id` (格式: `user_xxx_session_yyy`) 或 `metadata.session_id` 提取 //! - Codex: 从 `previous_response_id` 或 headers 中的 `session_id` 提取 //! - 其他: 生成新的 UUID ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/handler_config.rs
src-tauri/src/proxy/handler_config.rs
//! Handler 配置模块 //! //! 定义各 API 处理器的配置结构和使用量解析器 use crate::app_config::AppType; use crate::proxy::usage::parser::TokenUsage; use serde_json::Value; /// 使用量解析器类型别名 pub type StreamUsageParser = fn(&[Value]) -> Option<TokenUsage>; pub type ResponseUsageParser = fn(&Value) -> Option<TokenUsage>; /// 模型提取器类型别名 /// 参数: (...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/forwarder.rs
src-tauri/src/proxy/forwarder.rs
//! 请求转发器 //! //! 负责将请求转发到上游Provider,支持故障转移 use super::{ body_filter::filter_private_params_with_whitelist, error::*, failover_switch::FailoverSwitchManager, provider_router::ProviderRouter, providers::{get_adapter, ProviderAdapter}, types::ProxyStatus, ProxyError, }; use crate::{app_config...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/response_handler.rs
src-tauri/src/proxy/response_handler.rs
//! Response Handler - 统一响应处理 //! //! 提供流式和非流式响应的统一处理接口 use super::session::ProxySession; use super::usage::parser::TokenUsage; use super::ProxyError; use bytes::Bytes; use futures::stream::{Stream, StreamExt}; use serde_json::Value; use std::sync::Arc; use std::time::{Duration, Instant}; use tokio::sync::Mutex; use t...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/error.rs
src-tauri/src/proxy/error.rs
use axum::{ http::StatusCode, response::{IntoResponse, Response}, Json, }; use serde_json::json; use thiserror::Error; #[derive(Debug, Error)] pub enum ProxyError { #[error("服务器已在运行")] AlreadyRunning, #[error("服务器未运行")] NotRunning, #[error("地址绑定失败: {0}")] BindFailed(String), ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/types.rs
src-tauri/src/proxy/types.rs
use serde::{Deserialize, Serialize}; /// 代理服务器配置 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ProxyConfig { /// 监听地址 pub listen_address: String, /// 监听端口 pub listen_port: u16, /// 最大重试次数 pub max_retries: u8, /// 请求超时时间(秒)- 已废弃,保留兼容 pub request_timeout: u64, /// 是否启用日志 ...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/mod.rs
src-tauri/src/proxy/mod.rs
//! 代理服务器模块 //! //! 提供本地HTTP代理服务,支持多Provider故障转移和请求透传 pub mod body_filter; pub mod circuit_breaker; pub mod error; pub mod error_mapper; pub(crate) mod failover_switch; mod forwarder; pub mod handler_config; pub mod handler_context; mod handlers; mod health; pub mod model_mapper; pub mod provider_router; pub mod provi...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/health.rs
src-tauri/src/proxy/health.rs
//! 健康检查器 //! //! 负责定期检查Provider健康状态(占位实现) // 占位实现,稍后添加完整逻辑 #[allow(dead_code)] pub struct HealthChecker;
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/server.rs
src-tauri/src/proxy/server.rs
//! HTTP代理服务器 //! //! 基于Axum的HTTP服务器,处理代理请求 use super::{ failover_switch::FailoverSwitchManager, handlers, provider_router::ProviderRouter, types::*, ProxyError, }; use crate::database::Database; use axum::{ routing::{get, post}, Router, }; use std::net::SocketAddr; use std::sync::Arc; use tokio::sync:...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/body_filter.rs
src-tauri/src/proxy/body_filter.rs
//! 请求体过滤模块 //! //! 过滤不应透传到上游的私有参数,防止内部信息泄露。 //! //! ## 过滤规则 //! - 以 `_` 开头的字段被视为私有参数,会被递归过滤 //! - 支持白名单机制,允许透传特定的 `_` 前缀字段 //! - 支持嵌套对象和数组的深度过滤 //! //! ## 使用场景 //! - `_internal_id`: 内部追踪 ID //! - `_debug_mode`: 调试标记 //! - `_session_token`: 会话令牌 //! - `_client_version`: 客户端版本 use serde_json::Value; use std::collection...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/handler_context.rs
src-tauri/src/proxy/handler_context.rs
//! 请求上下文模块 //! //! 提供请求生命周期的上下文管理,封装通用初始化逻辑 use crate::app_config::AppType; use crate::provider::Provider; use crate::proxy::{ extract_session_id, forwarder::RequestForwarder, server::ProxyState, types::AppProxyConfig, ProxyError, }; use axum::http::HeaderMap; use std::time::Instant; /// 流式超时配置 #[derive(Debu...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/failover_switch.rs
src-tauri/src/proxy/failover_switch.rs
//! 故障转移切换模块 //! //! 处理故障转移成功后的供应商切换逻辑,包括: //! - 去重控制(避免多个请求同时触发) //! - 数据库更新 //! - 托盘菜单更新 //! - 前端事件发射 //! - Live 备份更新 use crate::database::Database; use crate::error::AppError; use std::collections::HashSet; use std::str::FromStr; use std::sync::Arc; use tauri::{Emitter, Manager}; use tokio::sync::RwLock; /// 故障转移切...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/circuit_breaker.rs
src-tauri/src/proxy/circuit_breaker.rs
//! 熔断器模块 //! //! 实现熔断器模式,用于防止向不健康的供应商发送请求 use serde::{Deserialize, Serialize}; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::time::Instant; use tokio::sync::RwLock; /// 熔断器状态 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/claude.rs
src-tauri/src/proxy/providers/claude.rs
//! Claude (Anthropic) Provider Adapter //! //! 支持透传模式和 OpenRouter 兼容模式 //! //! ## 认证模式 //! - **Claude**: Anthropic 官方 API (x-api-key + anthropic-version) //! - **ClaudeAuth**: 中转服务 (仅 Bearer 认证,无 x-api-key) //! - **OpenRouter**: 已支持 Claude Code 兼容接口,默认透传(保留旧转换逻辑备用) use super::{AuthInfo, AuthStrategy, ProviderAdapter,...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/transform.rs
src-tauri/src/proxy/providers/transform.rs
//! 格式转换模块 //! //! 实现 Anthropic ↔ OpenAI 格式转换,用于 OpenRouter 支持 //! 参考: anthropic-proxy-rs use crate::provider::Provider; use crate::proxy::error::ProxyError; use serde_json::{json, Value}; /// 从 Provider 配置中获取模型映射 fn get_model_from_provider(model: &str, provider: &Provider, body: &Value) -> String { let env = pro...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/adapter.rs
src-tauri/src/proxy/providers/adapter.rs
//! Provider Adapter Trait //! //! 定义供应商适配器的统一接口,抽象不同上游供应商的处理逻辑。 use super::auth::AuthInfo; use crate::provider::Provider; use crate::proxy::error::ProxyError; use reqwest::RequestBuilder; use serde_json::Value; /// 供应商适配器 Trait /// /// 所有供应商适配器都需要实现此 trait,提供统一的接口来处理: /// - URL 构建 /// - 认证信息提取和头部注入 /// - 请求/响应格式转换(可...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/auth.rs
src-tauri/src/proxy/providers/auth.rs
//! Authentication Types //! //! 定义认证信息和认证策略,支持多种上游供应商的认证方式。 /// 认证信息 /// /// 包含 API Key 和对应的认证策略 #[derive(Debug, Clone)] pub struct AuthInfo { /// API Key pub api_key: String, /// 认证策略 pub strategy: AuthStrategy, /// OAuth access_token(用于 GoogleOAuth 策略) pub access_token: Option<String>, } im...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/mod.rs
src-tauri/src/proxy/providers/mod.rs
//! Provider Adapters Module //! //! 供应商适配器模块,提供统一的接口抽象不同上游供应商的处理逻辑。 //! //! ## 模块结构 //! - `adapter`: 定义 `ProviderAdapter` trait //! - `auth`: 认证类型和策略 //! - `claude`: Claude (Anthropic) 适配器 //! - `codex`: Codex (OpenAI) 适配器 //! - `gemini`: Gemini (Google) 适配器 //! - `models`: API 数据模型 //! - `transform`: 格式转换 mod adapte...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/gemini.rs
src-tauri/src/proxy/providers/gemini.rs
//! Gemini (Google) Provider Adapter //! //! 支持 API Key 和 OAuth 两种认证方式 //! //! ## 认证模式 //! - **Gemini**: API Key 认证 (x-goog-api-key) //! - **GeminiCli**: OAuth Bearer 认证 (用于 Gemini CLI) use super::{AuthInfo, AuthStrategy, ProviderAdapter, ProviderType}; use crate::provider::Provider; use crate::proxy::error::ProxyErro...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/codex.rs
src-tauri/src/proxy/providers/codex.rs
//! Codex (OpenAI) Provider Adapter //! //! 仅透传模式,支持直连 OpenAI API //! //! ## 客户端检测 //! 支持检测官方 Codex 客户端 (codex_vscode, codex_cli_rs) use super::{AuthInfo, AuthStrategy, ProviderAdapter}; use crate::provider::Provider; use crate::proxy::error::ProxyError; use regex::Regex; use reqwest::RequestBuilder; use std::sync::La...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/streaming.rs
src-tauri/src/proxy/providers/streaming.rs
//! 流式响应转换模块 //! //! 实现 OpenAI SSE → Anthropic SSE 格式转换 use bytes::Bytes; use futures::stream::{Stream, StreamExt}; use serde::{Deserialize, Serialize}; use serde_json::json; /// OpenAI 流式响应数据结构 #[derive(Debug, Deserialize)] struct OpenAIStreamChunk { id: String, model: String, choices: Vec<StreamChoice>,...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false
farion1231/cc-switch
https://github.com/farion1231/cc-switch/blob/32149b1eeb6663445ffbd956d38631109935407b/src-tauri/src/proxy/providers/models/openai.rs
src-tauri/src/proxy/providers/models/openai.rs
//! OpenAI API 数据模型 //! //! 用于 OpenAI Chat Completions API 的请求/响应格式转换 use serde::{Deserialize, Serialize}; use serde_json::Value; /// OpenAI 请求 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OpenAIRequest { pub model: String, pub messages: Vec<OpenAIMessage>, #[serde(skip_serializing_if = "Opt...
rust
MIT
32149b1eeb6663445ffbd956d38631109935407b
2026-01-04T15:46:09.354064Z
false