Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdyer committed Jul 3, 2024
1 parent b612025 commit f9dc3cf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ static DEEPGRAM_BASE_URL: &str = "https://api.deepgram.com";
pub struct Deepgram {
#[cfg_attr(not(feature = "live"), allow(unused))]
api_key: String,
#[cfg_attr(all(not(feature = "live"), not(feature = "prerecorded")), allow(unused))]
#[cfg_attr(
all(not(feature = "live"), not(feature = "prerecorded")),
allow(unused)
)]
base_url: Url,
client: reqwest::Client,
}
Expand Down
14 changes: 6 additions & 8 deletions src/transcription/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl Transcription<'_> {
}
url
}

}

impl FileChunker {
Expand Down Expand Up @@ -231,10 +230,10 @@ where
}
}

let mut source = self.source
.ok_or(DeepgramError::NoSource)?
.map(|res| res.map(|bytes| Message::binary(Vec::from(bytes.as_ref()))));

let mut source = self
.source
.ok_or(DeepgramError::NoSource)?
.map(|res| res.map(|bytes| Message::binary(Vec::from(bytes.as_ref()))));

let request = Request::builder()
.method("GET")
Expand Down Expand Up @@ -299,7 +298,7 @@ where
}

#[cfg(test)]
mod tests{
mod tests {
#[test]
fn test_stream_url() {
let dg = crate::Deepgram::new("token");
Expand All @@ -317,5 +316,4 @@ mod tests{
"ws://localhost:8080/v1/listen",
);
}

}
}
14 changes: 9 additions & 5 deletions src/transcription/prerecorded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ impl Transcription<'_> {
.query(&[("callback", callback)])
}


fn listen_url(&self) -> Url {
self.0.base_url.join(DEEPGRAM_API_URL_LISTEN).unwrap()
}
Expand All @@ -282,13 +281,18 @@ mod tests {
#[test]
fn listen_url() {
let dg = Deepgram::new("token");
assert_eq!(&dg.transcription().listen_url().to_string(), "https://api.deepgram.com/v1/listen");
assert_eq!(
&dg.transcription().listen_url().to_string(),
"https://api.deepgram.com/v1/listen"
);
}

#[test]
fn listen_url_custom_host() {
let dg = Deepgram::with_base_url("token", "http://localhost:8888/abc/");
assert_eq!(&dg.transcription().listen_url().to_string(), "http://localhost:8888/abc/v1/listen");
assert_eq!(
&dg.transcription().listen_url().to_string(),
"http://localhost:8888/abc/v1/listen"
);
}

}
}

0 comments on commit f9dc3cf

Please sign in to comment.