<commit_before>//! Internal client
//!
//! Do not use directly - use the [`Algorithmia`](../struct.Algorithmia.html) struct instead
use http::header::HeaderValue;
use headers_ext::{Authorization, HeaderMapExt, UserAgent, authorization::Credentials};
use http::header::HeaderMap;
use reqwest::{Client, IntoUrl, Method, RequestBuilder, Url};
use std::str::FromStr;
use std::sync::Arc;

use crate::error::{ErrorKind, Result, ResultExt};
pub use reqwest::Body;

struct Simple(HeaderValue);
impl Credentials for Simple {
    const SCHEME: &'static str = "Simple";
    fn decode(value: &HeaderValue) -> Option<Self> {
        debug_assert!(
            value.as_bytes().starts_with(b"Simple "),
            "HeaderValue to decode should start with \"Simple ..\", received = {:?}",
            value,
        );

        Some(Simple(value.clone()))
    }
    fn encode(&self) -> HeaderValue {
        self.0.clone()
    }
}

impl Simple {
    /// Try to create a `Simple` authorization header.
    pub fn new(token: &str) -> Result<Self> {
        HeaderValue::from_str(&format!("Simple {}", token))
            .map(Simple)
            .map_err(|_| ErrorKind::InvalidApiKey.into())
    }<commit_msg>cargo fmt<commit_after>//! Internal client
//!
//! Do not use directly - use the [`Algorithmia`](../struct.Algorithmia.html) struct instead
use headers_ext::{authorization::Credentials, Authorization, HeaderMapExt, UserAgent};
use http::header::HeaderMap;
use http::header::HeaderValue;
use reqwest::{Client, IntoUrl, Method, RequestBuilder, Url};
use std::str::FromStr;
use std::sync::Arc;

use crate::error::{ErrorKind, Result, ResultExt};
pub use reqwest::Body;

struct Simple(HeaderValue);
impl Credentials for Simple {
    const SCHEME: &'static str = "Simple";
    fn decode(value: &HeaderValue) -> Option<Self> {
        debug_assert!(
            value.as_bytes().starts_with(b"Simple "),
            "HeaderValue to decode should start with \"Simple ..\", received = {:?}",
            value,
        );

        Some(Simple(value.clone()))
    }
    fn encode(&self) -> HeaderValue {
        self.0.clone()
    }
}

impl Simple {
    /// Try to create a `Simple` authorization header.
    pub fn new(token: &str) -> Result<Self> {
        HeaderValue::from_str(&format!("Simple {}", token))
            .map(Simple)
            .map_err(|_| ErrorKind::InvalidApiKey.into())
    }
{'fraction_non_alphanumeric': 0.1570109151973132, 'fraction_numerical': 0.0008396305625524769, 'mean_word_length': 3.285971223021583, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '86661', 'n_tokens_mistral': 708, 'n_tokens_neox': 708, 'n_words': 177}