46 lines
961 B
Rust
46 lines
961 B
Rust
use serde::Serialize;
|
|
use std::sync::Arc;
|
|
use foo::{Bar as Baz, Qux};
|
|
|
|
/// 桌面端列表里的一行代理。
|
|
/// 后面还有一句。
|
|
pub struct AgentRow {
|
|
pub id: Uuid,
|
|
name: String,
|
|
}
|
|
|
|
pub(crate) struct CrateOnly {
|
|
pub(super) up: u8,
|
|
}
|
|
|
|
/// 这个代理现在处在哪一步。
|
|
pub enum AgentState {
|
|
Idle,
|
|
Running { pid: u32 },
|
|
Failed(String),
|
|
}
|
|
|
|
impl AgentRow {
|
|
fn rename(&mut self, name: String) {}
|
|
}
|
|
|
|
/// 在本机拉起接口服务。
|
|
pub async fn start_server(addr: SocketAddr) -> Result<(), StartError> {
|
|
match result {
|
|
Ok(listener) => {
|
|
// 记下监听地址
|
|
self.listener = Some(listener);
|
|
}
|
|
Err(err) => {
|
|
// 返回 StartError
|
|
return Err(StartError);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 按 id 读写代理。
|
|
pub trait Store {
|
|
fn get(&self, id: Uuid) -> Result<AgentRow, StoreError>;
|
|
fn save(&mut self, row: AgentRow) -> Result<(), StoreError>;
|
|
}
|