Expand description
sift_rs
largely contains protobuf-generated code used to interact with Sift’s gRPC API as well as some
utility wrappers. Due to tonic relying on
tokio, it is required that users have tokio
installed
in order to communicate with Sift over gRPC.
§Quickstart
Start by installing sift_rs
cargo add sift_rs
Then install tokio
:
cargo add tokio --features full
Then we can establish a connection to Sift and use one of the protobuf service clients like so:
use sift_rs::{
Credentials, SiftChannelBuilder,
ping::v1::{PingRequest, ping_service_client::PingServiceClient},
};
use std::env;
#[tokio::main]
async fn main() {
let credentials = Credentials::Config {
apikey: env::var("SIFT_TOKEN").unwrap(),
uri: env::var("SIFT_GRPC").unwrap(),
};
let conn = SiftChannelBuilder::new(credentials).build().unwrap();
let mut ping_service = PingServiceClient::new(conn);
let ping_response = ping_service.ping(PingRequest::default()).await.unwrap();
println!("{}", ping_response.into_inner().response);
}
Re-exports§
pub use gen::sift::*;
Modules§
- gen
- Protobuf generated code to interface with Sift’s gRPC API.
- wrappers
- Utility wrappers for select gRPC services.
Structs§
- Sift
Channel Builder - Used to build an instance of SiftChannel.
Enums§
- Credentials
- Specifies source of credentials. If
Profile
is used, then the provided string will be used to query the corresponding table fromSIFT_CONFIG_NAME
located at these locations depending on your operating system. IfNone
is provided, then the top-level table is used.
Type Aliases§
- Sift
Channel - A pre-configured gRPC channel to conveniently establish a connection to Sift’s gRPC API.