pub struct ProviderService;Expand description
供应商相关业务逻辑
Implementations§
Source§impl ProviderService
impl ProviderService
Sourcepub fn get_custom_endpoints(
state: &AppState,
app_type: AppType,
provider_id: &str,
) -> Result<Vec<CustomEndpoint>, AppError>
pub fn get_custom_endpoints( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<Vec<CustomEndpoint>, AppError>
获取自定义端点列表
Sourcepub fn add_custom_endpoint(
state: &AppState,
app_type: AppType,
provider_id: &str,
url: String,
) -> Result<(), AppError>
pub fn add_custom_endpoint( state: &AppState, app_type: AppType, provider_id: &str, url: String, ) -> Result<(), AppError>
新增自定义端点
Source§impl ProviderService
impl ProviderService
Sourcepub async fn query_usage(
state: &AppState,
app_type: AppType,
provider_id: &str,
) -> Result<UsageResult, AppError>
pub async fn query_usage( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<UsageResult, AppError>
查询供应商用量(使用已保存的脚本配置)
Sourcepub async fn test_usage_script(
_state: &AppState,
_app_type: AppType,
_provider_id: &str,
script_code: &str,
timeout: u64,
api_key: Option<&str>,
base_url: Option<&str>,
access_token: Option<&str>,
user_id: Option<&str>,
template_type: Option<&str>,
) -> Result<UsageResult, AppError>
pub async fn test_usage_script( _state: &AppState, _app_type: AppType, _provider_id: &str, script_code: &str, timeout: u64, api_key: Option<&str>, base_url: Option<&str>, access_token: Option<&str>, user_id: Option<&str>, template_type: Option<&str>, ) -> Result<UsageResult, AppError>
测试用量脚本(使用临时脚本内容,不保存)
Source§impl ProviderService
impl ProviderService
pub fn sync_openclaw_to_live(state: &AppState) -> Result<(), AppError>
pub fn set_common_config_snippet( state: &AppState, app_type: AppType, snippet: Option<String>, ) -> Result<(), AppError>
pub fn clear_common_config_snippet( state: &AppState, app_type: AppType, ) -> Result<(), AppError>
Sourcepub fn list(
state: &AppState,
app_type: AppType,
) -> Result<IndexMap<String, Provider>, AppError>
pub fn list( state: &AppState, app_type: AppType, ) -> Result<IndexMap<String, Provider>, AppError>
列出指定应用下的所有供应商
Sourcepub fn add(
state: &AppState,
app_type: AppType,
provider: Provider,
) -> Result<bool, AppError>
pub fn add( state: &AppState, app_type: AppType, provider: Provider, ) -> Result<bool, AppError>
新增供应商
Sourcepub fn update(
state: &AppState,
app_type: AppType,
provider: Provider,
) -> Result<bool, AppError>
pub fn update( state: &AppState, app_type: AppType, provider: Provider, ) -> Result<bool, AppError>
更新供应商
Sourcepub fn import_default_config(
state: &AppState,
app_type: AppType,
) -> Result<bool, AppError>
pub fn import_default_config( state: &AppState, app_type: AppType, ) -> Result<bool, AppError>
导入当前 live 配置为默认供应商。
返回 Ok(true) 表示实际导入,Ok(false) 表示该 app 已有非官方 seed provider 而跳过。
Sourcepub fn update_sort_order(
state: &AppState,
app_type: AppType,
updates: Vec<ProviderSortUpdate>,
) -> Result<bool, AppError>
pub fn update_sort_order( state: &AppState, app_type: AppType, updates: Vec<ProviderSortUpdate>, ) -> Result<bool, AppError>
更新供应商排序
pub fn remove_from_live_config( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<(), AppError>
Sourcepub fn sync_current_to_live(state: &AppState) -> Result<(), AppError>
pub fn sync_current_to_live(state: &AppState) -> Result<(), AppError>
将所有应用的当前供应商配置同步到 live 文件。
用于 WebDAV 下载、备份恢复等场景:数据库已更新,但 live 配置文件
(~/.codex/config.toml、Claude settings.json 等)尚未同步。
对齐上游 sync_current_to_live 行为。
Sourcepub fn switch(
state: &AppState,
app_type: AppType,
provider_id: &str,
) -> Result<(), AppError>
pub fn switch( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<(), AppError>
切换指定应用的供应商
pub fn delete( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<(), AppError>
pub fn import_openclaw_providers_from_live( state: &AppState, ) -> Result<usize, AppError>
pub fn import_opencode_providers_from_live( state: &AppState, ) -> Result<usize, AppError>
Auto Trait Implementations§
impl Freeze for ProviderService
impl RefUnwindSafe for ProviderService
impl Send for ProviderService
impl Sync for ProviderService
impl Unpin for ProviderService
impl UnsafeUnpin for ProviderService
impl UnwindSafe for ProviderService
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