use super::proto::models::{self, SdkType};
pub const CLIENT_TYPE: &str = "stream-rust";
pub const SDK_TYPE: SdkType = SdkType::Unspecified;
pub const WEBRTC_VERSION: &str = "webrtc-rs-0.17.2";
pub fn sdk_name() -> &'static str {
CLIENT_TYPE
}
pub fn sdk_version() -> String {
env!("CARGO_PKG_VERSION").to_owned()
}
pub fn client_header() -> String {
format!("{CLIENT_TYPE}-{}", env!("CARGO_PKG_VERSION"))
}
pub fn client_details() -> models::ClientDetails {
models::ClientDetails {
sdk: Some(models::Sdk {
r#type: SDK_TYPE as i32,
major: env!("CARGO_PKG_VERSION_MAJOR").to_owned(),
minor: env!("CARGO_PKG_VERSION_MINOR").to_owned(),
patch: env!("CARGO_PKG_VERSION_PATCH").to_owned(),
}),
..Default::default()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn never_reports_go_sdk_type() {
assert_ne!(SDK_TYPE, SdkType::Go);
assert_eq!(SDK_TYPE, SdkType::Unspecified);
}
#[test]
fn client_header_is_stream_rust_versioned() {
let header = client_header();
assert!(header.starts_with("stream-rust-"));
assert!(!header.contains("go"));
}
#[test]
fn client_details_carry_non_go_sdk() {
let details = client_details();
let sdk = details.sdk.expect("sdk populated");
assert_eq!(sdk.r#type, SdkType::Unspecified as i32);
assert_ne!(sdk.r#type, SdkType::Go as i32);
}
}