Skip to content

Commit

Permalink
CredentialsProvider trait is non-Rusty
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Jun 20, 2020
1 parent 4cd54da commit 32852b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
4 changes: 2 additions & 2 deletions libsignal-service-actix/src/push_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ impl PushService for AwcPushService {
}

impl AwcPushService {
pub fn new<T: CredentialsProvider>(
pub fn new(
_cfg: ServiceConfiguration,
_credentials: T,
_credentials: Credentials,
user_agent: &str,
) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion libsignal-service/examples/registering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn main() -> Result<(), Error> {
let password = args.get_password()?;

let config = ServiceConfiguration::default();
let credentials = StaticCredentialsProvider {
let credentials = Credentials {
uuid: String::new(),
e164: args.username,
password,
Expand Down
18 changes: 1 addition & 17 deletions libsignal-service/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,8 @@ pub struct ServiceConfiguration {
pub contact_discovery_url: Vec<String>,
}

pub trait CredentialsProvider {
fn get_uuid(&self) -> String;

fn get_e164(&self) -> String;

fn get_password(&self) -> String;
}

pub struct StaticCredentialsProvider {
pub struct Credentials {
pub uuid: String,
pub e164: String,
pub password: String,
}

impl CredentialsProvider for StaticCredentialsProvider {
fn get_uuid(&self) -> String { self.uuid.clone() }

fn get_e164(&self) -> String { self.e164.clone() }

fn get_password(&self) -> String { self.password.clone() }
}
6 changes: 3 additions & 3 deletions libsignal-service/src/push_service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::configuration::{CredentialsProvider, ServiceConfiguration};
use crate::configuration::{Credentials, ServiceConfiguration};

pub const CREATE_ACCOUNT_SMS_PATH: &str = "/v1/accounts/sms/code/%s?client=%s";
pub const CREATE_ACCOUNT_VOICE_PATH: &str = "/v1/accounts/voice/code/%s";
Expand Down Expand Up @@ -66,9 +66,9 @@ pub struct PanicingPushService;
impl PanicingPushService {
/// A PushService implementation typically takes a ServiceConfiguration,
/// credentials and a user agent.
pub fn new<T: CredentialsProvider>(
pub fn new(
_cfg: ServiceConfiguration,
_credentials: T,
_credentials: Credentials,
_user_agent: &str,
) -> Self {
Self
Expand Down

0 comments on commit 32852b1

Please sign in to comment.