sonic channel
v1.1.0
ไคลเอ็นต์สนิมสำหรับแบ็กเอนด์การค้นหาเกี่ยวกับเสียง
เราขอแนะนำให้คุณเริ่มต้นด้วยเอกสารประกอบ
MSRV คือ: 1.58.1
เพิ่ม sonic-channel = { version = "1.1" }
เป็นการพึ่งพาใน Cargo.toml
ตัวอย่าง Cargo.toml
:
[ package ]
name = " my-crate "
version = " 0.1.0 "
authors = [ " Me <[email protected]> " ]
[ dependencies ]
sonic-channel = { version = " 1.1 " , features = [ " ingest " ] }
เพิ่ม default-features = false
ให้กับการพึ่งพา หากคุณต้องการยกเว้นช่องทางการ search
เริ่มต้น
หมายเหตุ: ตัวอย่างนี้จำเป็นต้องเปิดใช้งานคุณลักษณะ search
ซึ่งเปิดใช้งานตามค่าเริ่มต้น
use sonic_channel :: * ;
fn main ( ) -> result :: Result < ( ) > {
let channel = SearchChannel :: start (
"localhost:1491" ,
"SecretPassword" ,
) ? ;
let objects = channel . query ( QueryRequest :: new (
Dest :: col_buc ( "collection" , "bucket" ) ,
"recipe" ,
) ) ? ;
dbg ! ( objects ) ;
Ok ( ( ) )
}
หมายเหตุ: ตัวอย่างนี้จำเป็นต้องเปิดใช้งานคุณลักษณะ ingest
use sonic_channel :: * ;
fn main ( ) -> result :: Result < ( ) > {
let channel = IngestChannel :: start (
"localhost:1491" ,
"SecretPassword" ,
) ? ;
let dest = Dest :: col_buc ( "collection" , "bucket" ) . obj ( "object:1" ) ;
let pushed = channel . push ( PushRequest :: new ( dest , "my best recipe" ) ) ? ;
// or
// let pushed = channel.push(
// PushRequest::new(dest, "Мой лучший рецепт").lang(Lang::Rus)
// )?;
dbg ! ( pushed ) ;
Ok ( ( ) )
}
หมายเหตุ: ตัวอย่างนี้จำเป็นต้องเปิดใช้งานคุณสมบัติ control
use sonic_channel :: * ;
fn main ( ) -> result :: Result < ( ) > {
let channel = ControlChannel :: start (
"localhost:1491" ,
"SecretPassword" ,
) ? ;
let result = channel . consolidate ( ) ? ;
assert_eq ! ( result, ( ) ) ;
Ok ( ( ) )
}