pub struct OneBotConfig {
pub access_token: Option<String>,
pub mode: OneBotTransport,
}Expand description
适配器配置。端点 / 绑定完全落在 mode 里(如默认正向 WS 模式的
OneBotTransport::Forward { url })。
Fields§
§access_token: Option<String>§mode: OneBotTransport传输模式。默认 Forward { url }。
Implementations§
Source§impl OneBotConfig
impl OneBotConfig
Sourcepub fn new(url: impl Into<String>) -> OneBotConfig
pub fn new(url: impl Into<String>) -> OneBotConfig
正向 WS 配置(默认模式),如 ws://127.0.0.1:8080/onebot/v11/ws。
Examples found in repository?
More examples
Sourcepub fn reverse_ws(bind: SocketAddr, path: impl Into<String>) -> OneBotConfig
pub fn reverse_ws(bind: SocketAddr, path: impl Into<String>) -> OneBotConfig
反向 WS 配置:nagisa 绑 bind,在 path 上接受 WS 升级。
Sourcepub fn http(
api_url: impl Into<String>,
post_bind: SocketAddr,
post_path: impl Into<String>,
) -> OneBotConfig
pub fn http( api_url: impl Into<String>, post_bind: SocketAddr, post_path: impl Into<String>, ) -> OneBotConfig
HTTP-POST 配置:事件 POST 到 post_bind+post_path,动作发往 api_url。
Sourcepub fn http_api(api_url: impl Into<String>) -> OneBotConfig
pub fn http_api(api_url: impl Into<String>) -> OneBotConfig
纯 HTTP-API 动作配置:动作 POST 到 api_url,不起 webhook。与独立的纯事件适配器
(Forward/ReverseWs)配对,即可实现「HTTP 动作 + WS 事件」的拆分。
Sourcepub fn llonebot_http_sse(api_url: impl Into<String>) -> OneBotConfig
pub fn llonebot_http_sse(api_url: impl Into<String>) -> OneBotConfig
LLOneBot HTTP 客户端 + SSE /_events 事件流:actions POST 到 api_url,
事件经 SSE 推送(首选)。无公网回调即可收事件。
Sourcepub fn llonebot_http_long_poll(
api_url: impl Into<String>,
interval: Duration,
) -> OneBotConfig
pub fn llonebot_http_long_poll( api_url: impl Into<String>, interval: Duration, ) -> OneBotConfig
LLOneBot HTTP 客户端 + get_event 长轮询事件源:actions POST 到 api_url,
每 interval 拉一批排队事件。SSE 不可用时的回退方案。
pub fn with_token(self, token: impl Into<String>) -> OneBotConfig
Sourcepub fn with_secret(self, secret: impl Into<String>) -> OneBotConfig
pub fn with_secret(self, secret: impl Into<String>) -> OneBotConfig
设置 HTTP-POST 的 X-Signature 密钥(仅 Http 模式有意义)。
Trait Implementations§
Source§impl Clone for OneBotConfig
impl Clone for OneBotConfig
Source§fn clone(&self) -> OneBotConfig
fn clone(&self) -> OneBotConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OneBotConfig
impl RefUnwindSafe for OneBotConfig
impl Send for OneBotConfig
impl Sync for OneBotConfig
impl Unpin for OneBotConfig
impl UnsafeUnpin for OneBotConfig
impl UnwindSafe for OneBotConfig
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