Suppress unused warnings and clean up workspace
This commit is contained in:
Generated
-9
@@ -833,15 +833,6 @@ version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084"
|
||||
|
||||
[[package]]
|
||||
name = "no_std_test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"prost",
|
||||
"roto-runtime",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
|
||||
+4
-2
@@ -6,13 +6,15 @@ members = [
|
||||
"benches",
|
||||
"roto-tonic",
|
||||
"examples/hello_world",
|
||||
"examples/no_std_test",
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"test_gen_project"
|
||||
"test_gen_project",
|
||||
"examples/no_std_test",
|
||||
]
|
||||
|
||||
resolver = "3"
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ name = "roto-benches"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[features]
|
||||
alloc = []
|
||||
|
||||
[dependencies]
|
||||
roto-runtime = { path = "../runtime" }
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
|
||||
@@ -3,6 +3,9 @@ name = "roto-codegen"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[features]
|
||||
alloc = []
|
||||
|
||||
[dependencies]
|
||||
|
||||
roto-runtime = { path = "../runtime" }
|
||||
|
||||
@@ -7,19 +7,23 @@ use crate::runtime::ProtoAccessor;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::str;
|
||||
|
||||
const DATA_IMPORTS: &str = "use roto_runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator, RotoMessage};\nuse core::str;\nuse bytes::{Bytes, BytesMut, Buf, BufMut};\n";
|
||||
const SERVICE_IMPORTS: &str = "use tonic::{Request, Response, Status};\n\
|
||||
use tokio_stream::Stream;\n\
|
||||
use std::pin::Pin;\n\
|
||||
use std::sync::Arc;\n\
|
||||
use std::task::{Context, Poll};\n\
|
||||
use std::future::Future;\n\
|
||||
use tonic::body::BoxBody;\n\
|
||||
use tower::Service;\n\
|
||||
use futures_util::StreamExt;\n\
|
||||
use http_body_util::BodyExt;\n\
|
||||
use http_body::Body;\n\
|
||||
use crate::{BufferPool, StatusBody};\n";
|
||||
const DATA_IMPORTS: &str = "#[allow(unused)]\n\
|
||||
use roto_runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator, RotoMessage};\n\
|
||||
use core::str;\n\
|
||||
use bytes::{Bytes, BytesMut, Buf, BufMut};\n";
|
||||
const SERVICE_IMPORTS: &str = "#[allow(unused)]\n\
|
||||
use tonic::{Request, Response, Status};\n\
|
||||
use tokio_stream::Stream;\n\
|
||||
use std::pin::Pin;\n\
|
||||
use std::sync::Arc;\n\
|
||||
use std::task::{Context, Poll};\n\
|
||||
use std::future::Future;\n\
|
||||
use tonic::body::BoxBody;\n\
|
||||
use tower::Service;\n\
|
||||
use futures_util::StreamExt;\n\
|
||||
use http_body_util::BodyExt;\n\
|
||||
use http_body::Body;\n\
|
||||
use crate::{BufferPool, StatusBody};\n";
|
||||
|
||||
pub fn to_pascal_case(s: &str) -> String {
|
||||
s.split('_')
|
||||
@@ -456,10 +460,7 @@ fn write_message(msg_proto: &DescriptorProto, output: &mut String) {
|
||||
|
||||
output.push_str(&format!(" pub fn finish(self) -> roto_runtime::Result<&'b mut [u8]> {{\n self.builder.finish()\n }}\n}}\n\n"));
|
||||
|
||||
output.push_str(&format!(
|
||||
"pub struct Owned{} {{\n",
|
||||
msg_name
|
||||
));
|
||||
output.push_str(&format!("pub struct Owned{} {{\n", msg_name));
|
||||
output.push_str(" pub data: bytes::Bytes,\n");
|
||||
output.push_str("}\n\n");
|
||||
|
||||
@@ -828,7 +829,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
output.push_str(SERVICE_IMPORTS);
|
||||
output.push_str("\n");
|
||||
let svc_name = to_pascal_case(svc_proto.name().unwrap());
|
||||
|
||||
|
||||
output.push_str(&format!(
|
||||
"#[async_trait::async_trait]\npub trait {}: Send + Sync + 'static {{\n",
|
||||
svc_name
|
||||
@@ -875,7 +876,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
output.push_str("}\n\n");
|
||||
|
||||
let server_name = format!("{}Server", svc_name);
|
||||
|
||||
|
||||
output.push_str(&format!(
|
||||
"#[derive(Clone)]\npub struct {} {{\n",
|
||||
server_name
|
||||
@@ -884,7 +885,6 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
output.push_str(" pool: Arc<BufferPool>,\n");
|
||||
output.push_str("}\n\n");
|
||||
|
||||
|
||||
output.push_str(&format!("impl {} {{\n", server_name));
|
||||
output.push_str(&format!(
|
||||
" pub fn new(inner: Arc<dyn {}>, pool: Arc<BufferPool>) -> Self {{\n",
|
||||
@@ -894,7 +894,6 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
output.push_str(" }\n");
|
||||
output.push_str("}\n\n");
|
||||
|
||||
|
||||
output.push_str(&format!(
|
||||
"impl tonic::server::NamedService for {} {{\n",
|
||||
server_name
|
||||
@@ -910,7 +909,6 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
));
|
||||
output.push_str("}\n\n");
|
||||
|
||||
|
||||
output.push_str(&format!(
|
||||
"impl Service<http::Request<BoxBody>> for {} {{\n",
|
||||
server_name
|
||||
@@ -946,7 +944,8 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
output.push_str(" return Ok(http::Response::builder().status(200).body(res_body).unwrap());\n");
|
||||
output.push_str(" }\n\n");
|
||||
output.push_str(" let payload = bytes_vec.slice(5..);\n");
|
||||
output.push_str(" let mut routed = false;\n\n");
|
||||
output.push_str(" #[allow(unused_assignments)]\n");
|
||||
output.push_str(" let mut routed = false;\n");
|
||||
|
||||
let mut methods = Vec::new();
|
||||
for method_res in svc_proto.method() {
|
||||
@@ -1003,7 +1002,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
input_owned
|
||||
));
|
||||
output.push_str(" Ok(msg) => msg,\n");
|
||||
output.push_str(" Err(e) => {\n");
|
||||
output.push_str(" Err(_e) => {\n");
|
||||
output.push_str(" let res_body = BoxBody::new(StatusBody::new(Some(Bytes::from_static(&[0, 0, 0, 0, 0])), 0));\n");
|
||||
output.push_str(" return Ok(http::Response::builder().status(200).body(res_body).unwrap());\n");
|
||||
output.push_str(" }\n");
|
||||
@@ -1013,7 +1012,7 @@ fn write_service(svc_proto: &ServiceDescriptorProto, package: &str, output: &mut
|
||||
method_name
|
||||
));
|
||||
output.push_str(" Ok(res) => res,\n");
|
||||
output.push_str(" Err(e) => {\n");
|
||||
output.push_str(" Err(_e) => {\n");
|
||||
output.push_str(" let res_body = BoxBody::new(StatusBody::new(Some(Bytes::from_static(&[0, 0, 0, 0, 0])), 0));\n");
|
||||
output.push_str(" return Ok(http::Response::builder().status(200).body(res_body).unwrap());\n");
|
||||
output.push_str(" }\n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @generated by protoc-gen-roto — do not edit
|
||||
#[allow(unused_imports)]
|
||||
#[allow(unused)]
|
||||
|
||||
use crate::runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator};
|
||||
use std::str;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @generated by protoc-gen-roto — do not edit
|
||||
#[allow(unused_imports)]
|
||||
#[allow(unused)]
|
||||
|
||||
use crate::runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator};
|
||||
use std::str;
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
use roto_codegen::generator::generate_rust_code;
|
||||
use roto_codegen::google::protobuf::descriptor::{
|
||||
DescriptorProto, FieldDescriptorProto, FileDescriptorSet,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
fn test_oneof_generation() {
|
||||
let mut set = FileDescriptorSet::new(b"").unwrap(); // Simplified for testing
|
||||
|
||||
// In a real scenario, we'd build up a FileDescriptorSet from a proto.
|
||||
// For this unit test, we'll manually construct a DescriptorProto that has a oneof.
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
fn main() {
|
||||
let proto_file = "proto/hello.proto";
|
||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||
let dest_path = std::path::Path::new(&out_dir).join("hello.rs");
|
||||
|
||||
// Find the protoc-gen-roto binary
|
||||
// Since we added roto-codegen to build-dependencies, it will be built.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @generated by protoc-gen-roto — do not edit
|
||||
#[allow(unused_imports)]
|
||||
#[allow(unused)]
|
||||
|
||||
use roto_runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator, RotoMessage};
|
||||
use std::str;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @generated by protoc-gen-roto — do not edit
|
||||
#[allow(unused_imports)]
|
||||
#![allow(unused)]
|
||||
use roto_runtime::{ProtoAccessor, ProtoBuilder, Result, RotoError, read_varint, RepeatedFieldIterator, RotoMessage};
|
||||
use core::str;
|
||||
use bytes::{Bytes, BytesMut, Buf, BufMut};
|
||||
|
||||
+12
-9
@@ -1,12 +1,11 @@
|
||||
use std::marker::PhantomData;
|
||||
use tonic::codec::{Codec, Decoder, Encoder, DecodeBuf, EncodeBuf};
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use roto_runtime::RotoMessage;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::pin::Pin;
|
||||
use std::future::Future;
|
||||
use std::task::{Context, Poll};
|
||||
use http_body::Body;
|
||||
use roto_runtime::RotoMessage;
|
||||
use std::marker::PhantomData;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Mutex;
|
||||
use std::task::{Context, Poll};
|
||||
use tonic::codec::{Codec, DecodeBuf, Decoder, EncodeBuf, Encoder};
|
||||
|
||||
pub mod generated {
|
||||
pub mod helloworld;
|
||||
@@ -95,7 +94,11 @@ impl BufferPool {
|
||||
}
|
||||
|
||||
pub fn get(&self) -> BytesMut {
|
||||
self.pool.lock().unwrap().pop().unwrap_or_else(|| BytesMut::with_capacity(self.default_capacity))
|
||||
self.pool
|
||||
.lock()
|
||||
.unwrap()
|
||||
.pop()
|
||||
.unwrap_or_else(|| BytesMut::with_capacity(self.default_capacity))
|
||||
}
|
||||
|
||||
pub fn put(&self, mut buf: BytesMut) {
|
||||
@@ -128,7 +131,7 @@ impl Body for StatusBody {
|
||||
|
||||
fn poll_frame(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
_cx: &mut Context<'_>,
|
||||
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
|
||||
if let Some(data) = self.data.take() {
|
||||
Poll::Ready(Some(Ok(http_body::Frame::data(data))))
|
||||
|
||||
@@ -6,7 +6,6 @@ use roto_runtime::RotoOwned;
|
||||
use roto_tonic::{BufferPool, generated::interop::{InteropService, InteropServiceServer, OwnedUnaryRequest, OwnedUnaryResponse, OwnedStreamingRequest, OwnedStreamingResponse, UnaryResponseBuilder}};
|
||||
use futures_util::Stream;
|
||||
use std::pin::Pin;
|
||||
use bytes::BufMut;
|
||||
|
||||
struct InteropHandler;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user