Crate cogs [] [src]

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

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())
    .keep_alive(true)
    .build(&handle);
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(), "")

Reexports

pub use cogs::*;

Modules

cogs

This module holds logic and data structures related to cognition services, called Cogs.

engine

Holds Engine related logic