<commit_before>use serde_json;
use hyper::{Url, Client, Error};
use hyper::client::Response;
use hyper::method::Method;
use hyper::status::StatusCode;
use hyper::header::{Headers, ContentType};
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;


pub struct SlackClient {
	webhook_url: Url,
	client: Client,
}

#[derive(Debug, Clone)]
pub enum WebhookError {
	Network,
	Rejected,
}

impl SlackClient {

	pub fn build(webhook_url: &str) -> Result<SlackClient, ()>
	{
		let tls_client = NativeTlsClient::new().unwrap();
		let webhook_hyper_url = Url::parse(webhook_url).map_err(|_| ())?;

		Ok(SlackClient {
			webhook_url: webhook_hyper_url,
			client: Client::with_connector(HttpsConnector::new(tls_client)),
		})
	}

	fn post(&self, json_body: &str) -> Result<Response, Error>
	{
		let mut headers = Headers::new();
		let content_type = ContentType("application/json".parse().expect("should not fail"));
		headers.set(content_type);

		let req1 = self.client.request(Method::Post, self.webhook_url.clone())
			.headers(headers.clone()).body(json_body);

		match req1.send() {
			Ok(r) => Ok(r),
			// retry (because the first attempt may fail due to reuse of closed sockets)
			// detail: https://github.com/hyperium/hyper/issues/796
			Err(_) => {
				let req2 = self.client.request(Method::Post, self.webhook_url.clone())
					.headers(headers).body(json_body);
				req2.send()
			}
		}
	}

	pub fn post_message(&self, message: &str) -> Result<(), WebhookError>
	{
		let payload = json!({"text": message});
		let body = serde_json::to_string(&payload).expect("should not fail");
		let result = self.post(&body);
		let res = result.map_err(|_| WebhookError::Network)?;

		match res.status {

			StatusCode::Ok => Ok(()),
			_ => Err(WebhookError::Rejected),
		}
	}
}
<commit_msg>Get rid of Hyper from SlackClient<commit_after>use reqwest::{Client, Url, StatusCode};

pub struct SlackClient {
	webhook_url: Url,
	client: Client,
}

#[derive(Debug, Clone)]
pub enum SlackError {
	Network,
	Rejected,
}

impl SlackClient {

	pub fn build(webhook_url: &str) -> Result<SlackClient, ()>
	{
		let webhook_url = Url::parse(webhook_url).map_err(|_| ())?;

		Ok(SlackClient {
			webhook_url: webhook_url,
			client: Client::new(),
		})
	}

	pub fn post_message(&self, message: &str) -> Result<(), SlackError>
	{
		let payload = json!({"text": message});

		let response = self.client.post(self.webhook_url.clone())
			.json(&payload)
			.send()
			.map_err(|_| SlackError::Network)?;

		match response.status() {
			StatusCode::Ok => Ok(()),
			_ => Err(SlackError::Rejected),
		}
	}
}

{'fraction_non_alphanumeric': 0.16820631254811394, 'fraction_numerical': 0.0026943802925327174, 'mean_word_length': 4.687089715536105, 'pattern_counts': {'":': 2, '<': 8, '<?xml version=': 0, '>': 19, 'https://': 1, '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': '1674192', 'n_tokens_mistral': 1010, 'n_tokens_neox': 934, 'n_words': 187}