#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Datetime};
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::sh_tangled::git::temp::get_tree;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LastCommit<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub author: Option<get_tree::Signature<'a>>,
#[serde(borrow)]
pub hash: CowStr<'a>,
#[serde(borrow)]
pub message: CowStr<'a>,
pub when: Datetime,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetTree<'a> {
#[serde(default = "_default_path")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub path: Option<CowStr<'a>>,
#[serde(borrow)]
pub r#ref: CowStr<'a>,
#[serde(borrow)]
pub repo: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetTreeOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub dotdot: Option<CowStr<'a>>,
#[serde(borrow)]
pub files: Vec<get_tree::TreeEntry<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub last_commit: Option<get_tree::LastCommit<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub parent: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub readme: Option<get_tree::Readme<'a>>,
#[serde(borrow)]
pub r#ref: CowStr<'a>,
}
#[open_union]
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic,
IntoStatic
)]
#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetTreeError<'a> {
#[serde(rename = "RepoNotFound")]
RepoNotFound(Option<CowStr<'a>>),
#[serde(rename = "RefNotFound")]
RefNotFound(Option<CowStr<'a>>),
#[serde(rename = "PathNotFound")]
PathNotFound(Option<CowStr<'a>>),
#[serde(rename = "InvalidRequest")]
InvalidRequest(Option<CowStr<'a>>),
}
impl core::fmt::Display for GetTreeError<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::RepoNotFound(msg) => {
write!(f, "RepoNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::RefNotFound(msg) => {
write!(f, "RefNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::PathNotFound(msg) => {
write!(f, "PathNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::InvalidRequest(msg) => {
write!(f, "InvalidRequest")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Readme<'a> {
#[serde(borrow)]
pub contents: CowStr<'a>,
#[serde(borrow)]
pub filename: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Signature<'a> {
#[serde(borrow)]
pub email: CowStr<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
pub when: Datetime,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TreeEntry<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub last_commit: Option<get_tree::LastCommit<'a>>,
#[serde(borrow)]
pub mode: CowStr<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
pub size: i64,
}
impl<'a> LexiconSchema for LastCommit<'a> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.getTree"
}
fn def_name() -> &'static str {
"lastCommit"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_getTree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct GetTreeResponse;
impl jacquard_common::xrpc::XrpcResp for GetTreeResponse {
const NSID: &'static str = "sh.tangled.git.temp.getTree";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetTreeOutput<'de>;
type Err<'de> = GetTreeError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetTree<'a> {
const NSID: &'static str = "sh.tangled.git.temp.getTree";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetTreeResponse;
}
pub struct GetTreeRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetTreeRequest {
const PATH: &'static str = "/xrpc/sh.tangled.git.temp.getTree";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetTree<'de>;
type Response = GetTreeResponse;
}
impl<'a> LexiconSchema for Readme<'a> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.getTree"
}
fn def_name() -> &'static str {
"readme"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_getTree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Signature<'a> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.getTree"
}
fn def_name() -> &'static str {
"signature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_getTree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for TreeEntry<'a> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.getTree"
}
fn def_name() -> &'static str {
"treeEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_getTree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod last_commit_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Hash;
type When;
type Message;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Hash = Unset;
type When = Unset;
type Message = Unset;
}
pub struct SetHash<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHash<S> {}
impl<S: State> State for SetHash<S> {
type Hash = Set<members::hash>;
type When = S::When;
type Message = S::Message;
}
pub struct SetWhen<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWhen<S> {}
impl<S: State> State for SetWhen<S> {
type Hash = S::Hash;
type When = Set<members::when>;
type Message = S::Message;
}
pub struct SetMessage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMessage<S> {}
impl<S: State> State for SetMessage<S> {
type Hash = S::Hash;
type When = S::When;
type Message = Set<members::message>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct hash(());
pub struct when(());
pub struct message(());
}
}
pub struct LastCommitBuilder<'a, S: last_commit_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<get_tree::Signature<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LastCommit<'a> {
pub fn new() -> LastCommitBuilder<'a, last_commit_state::Empty> {
LastCommitBuilder::new()
}
}
impl<'a> LastCommitBuilder<'a, last_commit_state::Empty> {
pub fn new() -> Self {
LastCommitBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: last_commit_state::State> LastCommitBuilder<'a, S> {
pub fn author(mut self, value: impl Into<Option<get_tree::Signature<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_author(mut self, value: Option<get_tree::Signature<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> LastCommitBuilder<'a, S>
where
S: last_commit_state::State,
S::Hash: last_commit_state::IsUnset,
{
pub fn hash(
mut self,
value: impl Into<CowStr<'a>>,
) -> LastCommitBuilder<'a, last_commit_state::SetHash<S>> {
self._fields.1 = Option::Some(value.into());
LastCommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LastCommitBuilder<'a, S>
where
S: last_commit_state::State,
S::Message: last_commit_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<CowStr<'a>>,
) -> LastCommitBuilder<'a, last_commit_state::SetMessage<S>> {
self._fields.2 = Option::Some(value.into());
LastCommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LastCommitBuilder<'a, S>
where
S: last_commit_state::State,
S::When: last_commit_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> LastCommitBuilder<'a, last_commit_state::SetWhen<S>> {
self._fields.3 = Option::Some(value.into());
LastCommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LastCommitBuilder<'a, S>
where
S: last_commit_state::State,
S::Hash: last_commit_state::IsSet,
S::When: last_commit_state::IsSet,
S::Message: last_commit_state::IsSet,
{
pub fn build(self) -> LastCommit<'a> {
LastCommit {
author: self._fields.0,
hash: self._fields.1.unwrap(),
message: self._fields.2.unwrap(),
when: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> LastCommit<'a> {
LastCommit {
author: self._fields.0,
hash: self._fields.1.unwrap(),
message: self._fields.2.unwrap(),
when: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_git_temp_getTree() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("sh.tangled.git.temp.getTree"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("lastCommit"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("hash"), SmolStr::new_static("message"),
SmolStr::new_static("when")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#signature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hash"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Commit hash")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Commit message")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("when"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Commit timestamp")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(
vec![
SmolStr::new_static("repo"), SmolStr::new_static("ref")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("path"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Path within the repository tree"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ref"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Git reference (branch, tag, or commit SHA)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repo"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("AT-URI of the repository"),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("readme"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("filename"),
SmolStr::new_static("contents")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("contents"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Contents of the readme file"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("filename"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Name of the readme file"),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signature"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("email"),
SmolStr::new_static("when")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("email"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Author email")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Author name")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("when"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Author timestamp")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("treeEntry"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("mode"),
SmolStr::new_static("size")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("last_commit"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#lastCommit"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mode"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("File mode")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Relative file or directory name"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_path() -> Option<CowStr<'static>> {
Some(CowStr::from(""))
}
pub mod get_tree_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Repo;
type Ref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Repo = Unset;
type Ref = Unset;
}
pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRepo<S> {}
impl<S: State> State for SetRepo<S> {
type Repo = Set<members::repo>;
type Ref = S::Ref;
}
pub struct SetRef<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRef<S> {}
impl<S: State> State for SetRef<S> {
type Repo = S::Repo;
type Ref = Set<members::r#ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct repo(());
pub struct r#ref(());
}
}
pub struct GetTreeBuilder<'a, S: get_tree_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetTree<'a> {
pub fn new() -> GetTreeBuilder<'a, get_tree_state::Empty> {
GetTreeBuilder::new()
}
}
impl<'a> GetTreeBuilder<'a, get_tree_state::Empty> {
pub fn new() -> Self {
GetTreeBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_tree_state::State> GetTreeBuilder<'a, S> {
pub fn path(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_path(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> GetTreeBuilder<'a, S>
where
S: get_tree_state::State,
S::Ref: get_tree_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<CowStr<'a>>,
) -> GetTreeBuilder<'a, get_tree_state::SetRef<S>> {
self._fields.1 = Option::Some(value.into());
GetTreeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetTreeBuilder<'a, S>
where
S: get_tree_state::State,
S::Repo: get_tree_state::IsUnset,
{
pub fn repo(
mut self,
value: impl Into<AtUri<'a>>,
) -> GetTreeBuilder<'a, get_tree_state::SetRepo<S>> {
self._fields.2 = Option::Some(value.into());
GetTreeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetTreeBuilder<'a, S>
where
S: get_tree_state::State,
S::Repo: get_tree_state::IsSet,
S::Ref: get_tree_state::IsSet,
{
pub fn build(self) -> GetTree<'a> {
GetTree {
path: self._fields.0,
r#ref: self._fields.1.unwrap(),
repo: self._fields.2.unwrap(),
}
}
}
pub mod signature_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type When;
type Name;
type Email;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type When = Unset;
type Name = Unset;
type Email = Unset;
}
pub struct SetWhen<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWhen<S> {}
impl<S: State> State for SetWhen<S> {
type When = Set<members::when>;
type Name = S::Name;
type Email = S::Email;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type When = S::When;
type Name = Set<members::name>;
type Email = S::Email;
}
pub struct SetEmail<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEmail<S> {}
impl<S: State> State for SetEmail<S> {
type When = S::When;
type Name = S::Name;
type Email = Set<members::email>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct when(());
pub struct name(());
pub struct email(());
}
}
pub struct SignatureBuilder<'a, S: signature_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Datetime>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Signature<'a> {
pub fn new() -> SignatureBuilder<'a, signature_state::Empty> {
SignatureBuilder::new()
}
}
impl<'a> SignatureBuilder<'a, signature_state::Empty> {
pub fn new() -> Self {
SignatureBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Email: signature_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<CowStr<'a>>,
) -> SignatureBuilder<'a, signature_state::SetEmail<S>> {
self._fields.0 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Name: signature_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> SignatureBuilder<'a, signature_state::SetName<S>> {
self._fields.1 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::When: signature_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> SignatureBuilder<'a, signature_state::SetWhen<S>> {
self._fields.2 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::When: signature_state::IsSet,
S::Name: signature_state::IsSet,
S::Email: signature_state::IsSet,
{
pub fn build(self) -> Signature<'a> {
Signature {
email: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
when: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Signature<'a> {
Signature {
email: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
when: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod tree_entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Size;
type Name;
type Mode;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Size = Unset;
type Name = Unset;
type Mode = Unset;
}
pub struct SetSize<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSize<S> {}
impl<S: State> State for SetSize<S> {
type Size = Set<members::size>;
type Name = S::Name;
type Mode = S::Mode;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Size = S::Size;
type Name = Set<members::name>;
type Mode = S::Mode;
}
pub struct SetMode<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMode<S> {}
impl<S: State> State for SetMode<S> {
type Size = S::Size;
type Name = S::Name;
type Mode = Set<members::mode>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct size(());
pub struct name(());
pub struct mode(());
}
}
pub struct TreeEntryBuilder<'a, S: tree_entry_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<get_tree::LastCommit<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<i64>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> TreeEntry<'a> {
pub fn new() -> TreeEntryBuilder<'a, tree_entry_state::Empty> {
TreeEntryBuilder::new()
}
}
impl<'a> TreeEntryBuilder<'a, tree_entry_state::Empty> {
pub fn new() -> Self {
TreeEntryBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: tree_entry_state::State> TreeEntryBuilder<'a, S> {
pub fn last_commit(
mut self,
value: impl Into<Option<get_tree::LastCommit<'a>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_last_commit(mut self, value: Option<get_tree::LastCommit<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> TreeEntryBuilder<'a, S>
where
S: tree_entry_state::State,
S::Mode: tree_entry_state::IsUnset,
{
pub fn mode(
mut self,
value: impl Into<CowStr<'a>>,
) -> TreeEntryBuilder<'a, tree_entry_state::SetMode<S>> {
self._fields.1 = Option::Some(value.into());
TreeEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TreeEntryBuilder<'a, S>
where
S: tree_entry_state::State,
S::Name: tree_entry_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> TreeEntryBuilder<'a, tree_entry_state::SetName<S>> {
self._fields.2 = Option::Some(value.into());
TreeEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TreeEntryBuilder<'a, S>
where
S: tree_entry_state::State,
S::Size: tree_entry_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> TreeEntryBuilder<'a, tree_entry_state::SetSize<S>> {
self._fields.3 = Option::Some(value.into());
TreeEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TreeEntryBuilder<'a, S>
where
S: tree_entry_state::State,
S::Size: tree_entry_state::IsSet,
S::Name: tree_entry_state::IsSet,
S::Mode: tree_entry_state::IsSet,
{
pub fn build(self) -> TreeEntry<'a> {
TreeEntry {
last_commit: self._fields.0,
mode: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
size: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> TreeEntry<'a> {
TreeEntry {
last_commit: self._fields.0,
mode: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
size: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}