chore: rebrand project to crank

This commit is contained in:
a.tolmachev
2026-03-28 00:58:56 +03:00
parent 6821d0c64a
commit 26335e8d9b
101 changed files with 550 additions and 538 deletions
+54
View File
@@ -0,0 +1,54 @@
use serde::{Deserialize, Serialize};
use crate::model::ProtoMessage;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ProtoScalarKind {
String,
Bool,
Int32,
Int64,
Uint32,
Uint64,
Float,
Double,
Bytes,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoEnum {
pub name: String,
pub values: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoMapField {
pub key: ProtoScalarKind,
pub value: Box<ProtoFieldType>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum ProtoFieldType {
Scalar { scalar: ProtoScalarKind },
Message { message: Box<ProtoMessage> },
Enum { enumeration: ProtoEnum },
Map { map: ProtoMapField },
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ProtoFieldCardinality {
Optional,
Required,
Repeated,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoField {
pub name: String,
pub json_name: String,
pub cardinality: ProtoFieldCardinality,
pub field_type: ProtoFieldType,
}
+16
View File
@@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};
use crate::model::ProtoField;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoOneof {
pub name: String,
pub variants: Vec<ProtoField>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoMessage {
pub name: String,
pub fields: Vec<ProtoField>,
pub oneofs: Vec<ProtoOneof>,
}
+18
View File
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};
use crate::model::ProtoMessage;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoMethod {
pub name: String,
pub input: ProtoMessage,
pub output: ProtoMessage,
pub client_streaming: bool,
pub server_streaming: bool,
}
impl ProtoMethod {
pub fn is_unary(&self) -> bool {
!self.client_streaming && !self.server_streaming
}
}
+11
View File
@@ -0,0 +1,11 @@
mod field;
mod message;
mod method;
mod service;
pub use field::{
ProtoEnum, ProtoField, ProtoFieldCardinality, ProtoFieldType, ProtoMapField, ProtoScalarKind,
};
pub use message::{ProtoMessage, ProtoOneof};
pub use method::ProtoMethod;
pub use service::ProtoService;
+16
View File
@@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};
use crate::model::ProtoMethod;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoService {
pub package: String,
pub name: String,
pub methods: Vec<ProtoMethod>,
}
impl ProtoService {
pub fn unary_methods(&self) -> impl Iterator<Item = &ProtoMethod> {
self.methods.iter().filter(|method| method.is_unary())
}
}