#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, 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::repo::tree;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LastCommit<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub author: Option<tree::Signature<S>>,
pub hash: S,
pub message: S,
pub when: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Tree<S: BosStr = DefaultStr> {
#[serde(default = "_default_path")]
#[serde(skip_serializing_if = "Option::is_none")]
pub path: Option<S>,
pub r#ref: S,
pub repo: S,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct TreeOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub dotdot: Option<S>,
pub files: Vec<tree::TreeEntry<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_commit: Option<tree::LastCommit<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parent: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub readme: Option<tree::Readme<S>>,
pub r#ref: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum TreeError {
#[serde(rename = "RepoNotFound")]
RepoNotFound(Option<SmolStr>),
#[serde(rename = "RefNotFound")]
RefNotFound(Option<SmolStr>),
#[serde(rename = "PathNotFound")]
PathNotFound(Option<SmolStr>),
#[serde(rename = "InvalidRequest")]
InvalidRequest(Option<SmolStr>),
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for TreeError {
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::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Readme<S: BosStr = DefaultStr> {
pub contents: S,
pub filename: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Signature<S: BosStr = DefaultStr> {
pub email: S,
pub name: S,
pub when: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct TreeEntry<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub last_commit: Option<tree::LastCommit<S>>,
pub mode: S,
pub name: S,
pub size: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for LastCommit<S> {
fn nsid() -> &'static str {
"sh.tangled.repo.tree"
}
fn def_name() -> &'static str {
"lastCommit"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo_tree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct TreeResponse;
impl jacquard_common::xrpc::XrpcResp for TreeResponse {
const NSID: &'static str = "sh.tangled.repo.tree";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = TreeOutput<S>;
type Err = TreeError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for Tree<S> {
const NSID: &'static str = "sh.tangled.repo.tree";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = TreeResponse;
}
pub struct TreeRequest;
impl jacquard_common::xrpc::XrpcEndpoint for TreeRequest {
const PATH: &'static str = "/xrpc/sh.tangled.repo.tree";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = Tree<S>;
type Response = TreeResponse;
}
impl<S: BosStr> LexiconSchema for Readme<S> {
fn nsid() -> &'static str {
"sh.tangled.repo.tree"
}
fn def_name() -> &'static str {
"readme"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo_tree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Signature<S> {
fn nsid() -> &'static str {
"sh.tangled.repo.tree"
}
fn def_name() -> &'static str {
"signature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo_tree()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for TreeEntry<S> {
fn nsid() -> &'static str {
"sh.tangled.repo.tree"
}
fn def_name() -> &'static str {
"treeEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo_tree()
}
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 Message;
type When;
type Hash;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Message = Unset;
type When = Unset;
type Hash = Unset;
}
pub struct SetMessage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMessage<St> {}
impl<St: State> State for SetMessage<St> {
type Message = Set<members::message>;
type When = St::When;
type Hash = St::Hash;
}
pub struct SetWhen<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWhen<St> {}
impl<St: State> State for SetWhen<St> {
type Message = St::Message;
type When = Set<members::when>;
type Hash = St::Hash;
}
pub struct SetHash<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHash<St> {}
impl<St: State> State for SetHash<St> {
type Message = St::Message;
type When = St::When;
type Hash = Set<members::hash>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct message(());
pub struct when(());
pub struct hash(());
}
}
pub struct LastCommitBuilder<S: BosStr, St: last_commit_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<tree::Signature<S>>, Option<S>, Option<S>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> LastCommit<S> {
pub fn new() -> LastCommitBuilder<S, last_commit_state::Empty> {
LastCommitBuilder::new()
}
}
impl<S: BosStr> LastCommitBuilder<S, last_commit_state::Empty> {
pub fn new() -> Self {
LastCommitBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: last_commit_state::State> LastCommitBuilder<S, St> {
pub fn author(mut self, value: impl Into<Option<tree::Signature<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_author(mut self, value: Option<tree::Signature<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> LastCommitBuilder<S, St>
where
St: last_commit_state::State,
St::Hash: last_commit_state::IsUnset,
{
pub fn hash(
mut self,
value: impl Into<S>,
) -> LastCommitBuilder<S, last_commit_state::SetHash<St>> {
self._fields.1 = Option::Some(value.into());
LastCommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LastCommitBuilder<S, St>
where
St: last_commit_state::State,
St::Message: last_commit_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<S>,
) -> LastCommitBuilder<S, last_commit_state::SetMessage<St>> {
self._fields.2 = Option::Some(value.into());
LastCommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LastCommitBuilder<S, St>
where
St: last_commit_state::State,
St::When: last_commit_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> LastCommitBuilder<S, last_commit_state::SetWhen<St>> {
self._fields.3 = Option::Some(value.into());
LastCommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LastCommitBuilder<S, St>
where
St: last_commit_state::State,
St::Message: last_commit_state::IsSet,
St::When: last_commit_state::IsSet,
St::Hash: last_commit_state::IsSet,
{
pub fn build(self) -> LastCommit<S> {
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<SmolStr, Data<S>>,
) -> LastCommit<S> {
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_repo_tree() -> 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.repo.tree"),
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(
"Repository identifier in format 'did:plc:.../repoName'",
),
),
..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<S: jacquard_common::FromStaticStr>() -> Option<S> {
Some(S::from_static(""))
}
pub mod 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 Ref;
type Repo;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Ref = Unset;
type Repo = Unset;
}
pub struct SetRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRef<St> {}
impl<St: State> State for SetRef<St> {
type Ref = Set<members::r#ref>;
type Repo = St::Repo;
}
pub struct SetRepo<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepo<St> {}
impl<St: State> State for SetRepo<St> {
type Ref = St::Ref;
type Repo = Set<members::repo>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#ref(());
pub struct repo(());
}
}
pub struct TreeBuilder<S: BosStr, St: tree_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Tree<S> {
pub fn new() -> TreeBuilder<S, tree_state::Empty> {
TreeBuilder::new()
}
}
impl<S: BosStr> TreeBuilder<S, tree_state::Empty> {
pub fn new() -> Self {
TreeBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: tree_state::State> TreeBuilder<S, St> {
pub fn path(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_path(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> TreeBuilder<S, St>
where
St: tree_state::State,
St::Ref: tree_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<S>,
) -> TreeBuilder<S, tree_state::SetRef<St>> {
self._fields.1 = Option::Some(value.into());
TreeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TreeBuilder<S, St>
where
St: tree_state::State,
St::Repo: tree_state::IsUnset,
{
pub fn repo(
mut self,
value: impl Into<S>,
) -> TreeBuilder<S, tree_state::SetRepo<St>> {
self._fields.2 = Option::Some(value.into());
TreeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TreeBuilder<S, St>
where
St: tree_state::State,
St::Ref: tree_state::IsSet,
St::Repo: tree_state::IsSet,
{
pub fn build(self) -> Tree<S> {
Tree {
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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWhen<St> {}
impl<St: State> State for SetWhen<St> {
type When = Set<members::when>;
type Name = St::Name;
type Email = St::Email;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type When = St::When;
type Name = Set<members::name>;
type Email = St::Email;
}
pub struct SetEmail<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEmail<St> {}
impl<St: State> State for SetEmail<St> {
type When = St::When;
type Name = St::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<S: BosStr, St: signature_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Signature<S> {
pub fn new() -> SignatureBuilder<S, signature_state::Empty> {
SignatureBuilder::new()
}
}
impl<S: BosStr> SignatureBuilder<S, signature_state::Empty> {
pub fn new() -> Self {
SignatureBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Email: signature_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<S>,
) -> SignatureBuilder<S, signature_state::SetEmail<St>> {
self._fields.0 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Name: signature_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> SignatureBuilder<S, signature_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::When: signature_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> SignatureBuilder<S, signature_state::SetWhen<St>> {
self._fields.2 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::When: signature_state::IsSet,
St::Name: signature_state::IsSet,
St::Email: signature_state::IsSet,
{
pub fn build(self) -> Signature<S> {
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<SmolStr, Data<S>>,
) -> Signature<S> {
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 Mode;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Size = Unset;
type Mode = Unset;
type Name = Unset;
}
pub struct SetSize<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSize<St> {}
impl<St: State> State for SetSize<St> {
type Size = Set<members::size>;
type Mode = St::Mode;
type Name = St::Name;
}
pub struct SetMode<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMode<St> {}
impl<St: State> State for SetMode<St> {
type Size = St::Size;
type Mode = Set<members::mode>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Size = St::Size;
type Mode = St::Mode;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct size(());
pub struct mode(());
pub struct name(());
}
}
pub struct TreeEntryBuilder<S: BosStr, St: tree_entry_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<tree::LastCommit<S>>, Option<S>, Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> TreeEntry<S> {
pub fn new() -> TreeEntryBuilder<S, tree_entry_state::Empty> {
TreeEntryBuilder::new()
}
}
impl<S: BosStr> TreeEntryBuilder<S, tree_entry_state::Empty> {
pub fn new() -> Self {
TreeEntryBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: tree_entry_state::State> TreeEntryBuilder<S, St> {
pub fn last_commit(mut self, value: impl Into<Option<tree::LastCommit<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_last_commit(mut self, value: Option<tree::LastCommit<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> TreeEntryBuilder<S, St>
where
St: tree_entry_state::State,
St::Mode: tree_entry_state::IsUnset,
{
pub fn mode(
mut self,
value: impl Into<S>,
) -> TreeEntryBuilder<S, tree_entry_state::SetMode<St>> {
self._fields.1 = Option::Some(value.into());
TreeEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TreeEntryBuilder<S, St>
where
St: tree_entry_state::State,
St::Name: tree_entry_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> TreeEntryBuilder<S, tree_entry_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
TreeEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TreeEntryBuilder<S, St>
where
St: tree_entry_state::State,
St::Size: tree_entry_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> TreeEntryBuilder<S, tree_entry_state::SetSize<St>> {
self._fields.3 = Option::Some(value.into());
TreeEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TreeEntryBuilder<S, St>
where
St: tree_entry_state::State,
St::Size: tree_entry_state::IsSet,
St::Mode: tree_entry_state::IsSet,
St::Name: tree_entry_state::IsSet,
{
pub fn build(self) -> TreeEntry<S> {
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<SmolStr, Data<S>>,
) -> TreeEntry<S> {
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),
}
}
}