4 releases

Uses old Rust 2015

0.1.1 Jun 15, 2017
0.1.0 Apr 1, 2017
0.0.4 Jun 15, 2017
0.0.1 Apr 1, 2017

#14 in #microsoft

MIT license

521 lines

Cogs Build Status

Non-blocking Microsoft Cognition APIs client for Rust.


Note: Since Tokio-based Hyper is not yet published to Crates.io, this lib hasn't been published yet either.



You'll need to clone this repo and specify a path.

cogs = { path = "$cloned_path" }

Command line

Clone this repo, cd into it, then run

cargo install

Then either set an AZURE_SUBSCRIPTION_KEY in your environment, or pass it in via command line.

cogs --from=en --to=de --repl

**************************** Cogs ****************************

Enter text and get back a translation. Ctrl+C to exit.

Hi, my name is Lloyd.
Hallo, ist mein Name Lloyd.
  1. Translation API docs here


Cogs is a non-blocking client for Microsoft cognition services

Although it is a WIP and not all the APIs are implemented, it contains enough infrastructure for you to being using it. All you need to do to add support for a new endpoint is to implement Cog (see cogs module) for your endpoint. To see an example of this, check the translations module.

Example usage

# extern crate hyper;
# extern crate hyper_tls;
# extern crate tokio_core;
# extern crate cogs;
# fn main() {
# use cogs::engine::*;
# use hyper_tls;
# use std::env;
# use cogs::cogs::translation::TranslateRequest;
let mut core = tokio_core::reactor::Core::new().unwrap();
let handle = core.handle();
let client = hyper::Client::configure()
    .connector(hyper_tls::HttpsConnector::new(4, &handle).unwrap())
# let sub_key = SubscriptionKey::new(env::var("AZURE_SUBSCRIPTION_KEY").unwrap().as_str());
let credentials = Credentials::new(sub_key);
let engine = Engine::new(credentials, client);
let translate_req = TranslateRequest {
    text: "Hello",
    from: Some("en"),
    to: "de",
    content_type: None,
    category: None,
let work = engine.run(translate_req);
// TODO: get a sandbox key so this actually comes back as "Hallo"
assert_eq!(core.run(work).unwrap(), "")
# }


~289K SLoC