use quote::quote;
pub(super) fn build_runtime_block() -> proc_macro2::TokenStream {
quote! {
#[derive(Clone, Copy)]
pub struct Cratestack;
#[derive(Clone)]
pub struct BoundCratestack {
ctx: ::cratestack::CoolContext,
}
pub struct CratestackBuilder;
impl Cratestack {
pub fn builder() -> CratestackBuilder {
CratestackBuilder
}
pub fn bind_context(&self, ctx: ::cratestack::CoolContext) -> BoundCratestack {
BoundCratestack { ctx }
}
pub fn bind_auth<P: ::cratestack::serde::Serialize>(
&self,
principal: Option<P>,
) -> Result<BoundCratestack, ::cratestack::CoolError> {
let ctx = ::cratestack::CoolContext::from_principal(principal)?;
Ok(self.bind_context(ctx))
}
}
impl BoundCratestack {
pub fn context(&self) -> &::cratestack::CoolContext {
&self.ctx
}
}
impl CratestackBuilder {
pub fn build(self) -> Cratestack {
Cratestack
}
}
pub fn schema_summary() -> ::cratestack::SchemaSummary {
::cratestack::SchemaSummary {
mixins: MIXINS,
models: MODELS,
types: TYPES,
enums: ENUMS,
procedures: PROCEDURES,
views: VIEWS,
}
}
}
}