pub struct ScoutConfig {
pub driver: String,
pub options: HashMap<String, Value>,
}Expand description
驱动配置。
真正生效的只有 driver 与 options:各便捷构造器
(ScoutConfig::elasticsearch 等)也只是写入这两者。
反序列化不拒绝未知键(未设 deny_unknown_fields),配置文件里多出来的
字段会被忽略而不是报错。
Debug 会把密钥打码(见下方手写实现):options 里
*.api_key / *secret* / *password* / *token 一律渲染成
"<redacted>",启动时打印配置不会再漏出凭据。
Serialize 仍按原样输出密钥——序列化是写配置文件的正常路径,
打码会破坏读回。要打日志请用 {:?},别用 serde_json::to_string。
Fields§
§driver: String§options: HashMap<String, Value>驱动专属参数,会被读取:键形如 elasticsearch.host /
database.url / algolia.app_id,由 EngineManager
在构造驱动时取用。
Implementations§
Source§impl ScoutConfig
impl ScoutConfig
pub fn collection() -> Self
pub fn elasticsearch(host: impl Into<String>, api_key: Option<String>) -> Self
pub fn opensearch(host: impl Into<String>, api_key: Option<String>) -> Self
pub fn meilisearch(host: impl Into<String>, api_key: impl Into<String>) -> Self
pub fn typesense(host: impl Into<String>, api_key: impl Into<String>) -> Self
pub fn algolia(app_id: impl Into<String>, api_key: impl Into<String>) -> Self
pub fn database(url: impl Into<String>) -> Self
pub fn null() -> Self
pub fn xunsearch(host: impl Into<String>, project: impl Into<String>) -> Self
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<Value>)
pub fn get(&self, key: &str) -> Option<&Value>
Trait Implementations§
Source§impl Clone for ScoutConfig
impl Clone for ScoutConfig
Source§impl Debug for ScoutConfig
impl Debug for ScoutConfig
Source§impl Default for ScoutConfig
impl Default for ScoutConfig
Source§impl<'de> Deserialize<'de> for ScoutConfig
impl<'de> Deserialize<'de> for ScoutConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Forget for ScoutConfig
impl Freeze for ScoutConfig
impl RefUnwindSafe for ScoutConfig
impl Send for ScoutConfig
impl Sync for ScoutConfig
impl Unpin for ScoutConfig
impl UnsafeUnpin for ScoutConfig
impl UnwindSafe for ScoutConfig
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