Skip to content

Instantly share code, notes, and snippets.

@carllerche
Created February 20, 2019 05:33
Show Gist options
  • Save carllerche/6e2351e1c3f968792cb898c08a726d96 to your computer and use it in GitHub Desktop.
Save carllerche/6e2351e1c3f968792cb898c08a726d96 to your computer and use it in GitHub Desktop.
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::v1::*;
#[macro_use]
extern crate std as std;
#[macro_use]
extern crate tower_web;
pub fn main() { }
pub struct Routes {
}
#[allow(unused_variables, non_upper_case_globals)]
const __IMPL_RESPONSE_FOR_Routes: () =
{
extern crate tower_web as __tw;
impl __tw::response::Response for Routes<> {
type
Buf
=
<Self::Body as __tw::util::BufStream>::Item;
type
Body
=
__tw::error::Map<__tw::codegen::bytes::Bytes>;
fn into_http<S: __tw::response::Serializer>(self,
context:
&__tw::response::Context<S>)
->
Result<__tw::codegen::http::Response<Self::Body>,
__tw::Error> {
struct Lift<'__a>(&'__a Routes<>);
impl <'__a> __tw::codegen::serde::Serialize for Lift<'__a> {
fn serialize<S>(&self, serializer: S)
-> ::std::result::Result<S::Ok, S::Error> where
S: __tw::codegen::serde::Serializer {
ShadowRoutes::serialize(self.0, serializer)
}
}
#[allow(unused_mut)]
let mut serializer_context = context.serializer_context();
let body: __tw::codegen::bytes::Bytes =
context.serialize(&Lift(&self),
&serializer_context).map_err(|_|
__tw::Error::from(http::status::StatusCode::INTERNAL_SERVER_ERROR))?;
let body = __tw::error::Map::new(body);
let mut response =
__tw::codegen::http::Response::builder().status("200").body(body).unwrap();
response.headers_mut().entry(__tw::codegen::http::header::CONTENT_TYPE).unwrap().or_insert_with(||
{
context.content_type_header().cloned().unwrap_or_else(||
{
__tw::codegen::http::header::HeaderValue::from_static("application/octet-stream")
})
});
Ok(response)
}
}
#[serde(remote = "Routes")]
pub struct ShadowRoutes {
}
#[allow(non_upper_case_globals,
unused_attributes,
unused_qualifications)]
const _IMPL_SERIALIZE_FOR_ShadowRoutes: () =
{
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate serde as _serde;
#[allow(unused_macros)]
macro_rules! try(( $ __expr : expr ) => {
match $ __expr {
_serde :: export :: Ok ( __val ) => __val ,
_serde :: export :: Err ( __err ) => {
return _serde :: export :: Err ( __err ) ; }
} });
impl ShadowRoutes {
pub fn serialize<__S>(__self: &Routes, __serializer: __S)
-> _serde::export::Result<__S::Ok, __S::Error> where
__S: _serde::Serializer {
match _serde::export::None::<ShadowRoutes> {
_serde::export::Some(ShadowRoutes { }) => { }
_ => { }
}
let __serde_state =
match _serde::Serializer::serialize_struct(__serializer,
"ShadowRoutes",
false
as
usize)
{
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
_serde::ser::SerializeStruct::end(__serde_state)
}
}
};
};
#[macro_use]
extern crate tower_web;
pub fn main() {
}
#[derive(Response)]
pub struct Routes {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment