Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cloudflare-e2e-test/src/storage_databases/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ fn get_random_title() -> String {
char::from(90),
))
.take(10)
.map(char::from)
.collect();
title
}
12 changes: 6 additions & 6 deletions cloudflare/src/endpoints/ai/execute_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl EndpointSpec for ExecuteModel<'_> {
}

#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down Expand Up @@ -320,12 +320,12 @@ pub enum MessageRole {
Assistant,
}

impl ToString for MessageRole {
fn to_string(&self) -> String {
impl std::fmt::Display for MessageRole {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MessageRole::System => "System".to_string(),
MessageRole::User => "User".to_string(),
MessageRole::Assistant => "Assistant".to_string(),
MessageRole::System => write!(formatter, "System"),
MessageRole::User => write!(formatter, "User"),
MessageRole::Assistant => write!(formatter, "Assistant"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/argo_tunnel/create_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl EndpointSpec for CreateTunnel<'_> {
format!("accounts/{}/tunnels", self.account_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/argo_tunnel/route_dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl EndpointSpec for RouteTunnel<'_> {
format!("zones/{}/tunnels/{}/routes", self.zone_tag, self.tunnel_id)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/cfd_tunnel/create_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl EndpointSpec for CreateTunnel<'_> {
format!("accounts/{}/cfd_tunnel", self.account_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/cfd_tunnel/route_dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl EndpointSpec for RouteTunnel<'_> {
format!("zones/{}/tunnels/{}/routes", self.zone_tag, self.tunnel_id)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/cfd_tunnel/update_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl EndpointSpec for UpdateTunnel<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
4 changes: 2 additions & 2 deletions cloudflare/src/endpoints/dns/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl EndpointSpec for CreateDnsRecord<'_> {
format!("zones/{}/dns_records", self.zone_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down Expand Up @@ -117,7 +117,7 @@ impl EndpointSpec for UpdateDnsRecord<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/load_balancing/create_lb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl EndpointSpec for CreateLoadBalancer<'_> {
format!("zones/{}/load_balancers", self.zone_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/load_balancing/create_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl EndpointSpec for CreatePool<'_> {
format!("accounts/{}/load_balancers/pools", self.account_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workers/create_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl EndpointSpec for CreateRoute<'_> {
format!("zones/{}/workers/routes", self.zone_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workers/create_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl EndpointSpec for CreateSecret<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workers/create_tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl EndpointSpec for CreateTail<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
if self.params.url.is_some() {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workerskv/create_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl EndpointSpec for CreateNamespace<'_> {
format!("accounts/{}/storage/kv/namespaces", self.account_identifier)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workerskv/delete_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl EndpointSpec for DeleteBulk<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
if self.bulk_keys.len() > 10_000 {
panic!("Bulk delete request can only contain up to 10,000 keys.");
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workerskv/rename_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl EndpointSpec for RenameNamespace<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workerskv/write_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl EndpointSpec for WriteBulk<'_> {
)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
if self.bulk_key_value_pairs.len() > 10_000 {
panic!("Bulk write request must have 10,000 key-value pairs or less.");
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/workerskv/write_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl EndpointSpec for WriteKey<'_> {
serialize_query(&self.params)
}
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
match &self.body {
WriteKeyBody::Value(value) => Some(RequestBody::Raw(value.clone())),
WriteKeyBody::Metadata(metadata) => Some(RequestBody::MultiPart(metadata)),
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/endpoints/zones/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl EndpointSpec for CreateZone<'_> {
}

#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
let body = serde_json::to_string(&self.params).unwrap();
Some(RequestBody::Json(body))
}
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/framework/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub mod spec {
///
/// Implementors should inline this.
#[inline]
fn body(&self) -> Option<RequestBody> {
fn body(&self) -> Option<RequestBody<'_>> {
None
}

Expand Down
2 changes: 1 addition & 1 deletion cloudflare/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum Environment {
Custom(String),
}

impl<'a> From<&'a Environment> for url::Url {
impl From<&Environment> for url::Url {
fn from(environment: &Environment) -> Self {
match environment {
Environment::Production => {
Expand Down
4 changes: 4 additions & 0 deletions cloudflare/src/framework/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ pub use api_fail::*;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use serde_json::value::Value as JsonValue;
use serde_with::{serde_as, DefaultOnNull};
use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::fmt::Debug;

#[serde_as]
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
pub struct ApiSuccess<ResultType> {
pub result: ResultType,
pub result_info: Option<JsonValue>,
#[serde(default)]
#[serde_as(deserialize_as = "DefaultOnNull")]
pub messages: Vec<ResponseInfo>,
#[serde(default)]
#[serde_as(deserialize_as = "DefaultOnNull")]
pub errors: Vec<ResponseInfo>,
}

Expand Down