mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 11:45:02 +01:00
improvements
This commit is contained in:
parent
13deef42fd
commit
c5d83fe776
7 changed files with 15 additions and 15 deletions
|
|
@ -32,7 +32,6 @@ struct Domain {
|
||||||
asserts: Vec<Assert>,
|
asserts: Vec<Assert>,
|
||||||
#[xml(child = "doc")]
|
#[xml(child = "doc")]
|
||||||
doc: Vec<Doc>,
|
doc: Vec<Doc>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, XmlRead)]
|
#[derive(Debug, XmlRead)]
|
||||||
|
|
@ -72,7 +71,6 @@ struct Method {
|
||||||
index: u16,
|
index: u16,
|
||||||
#[xml(child = "doc")]
|
#[xml(child = "doc")]
|
||||||
doc: Vec<Doc>,
|
doc: Vec<Doc>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, XmlRead)]
|
#[derive(Debug, XmlRead)]
|
||||||
|
|
@ -88,7 +86,6 @@ struct Field {
|
||||||
asserts: Vec<Assert>,
|
asserts: Vec<Assert>,
|
||||||
#[xml(child = "doc")]
|
#[xml(child = "doc")]
|
||||||
doc: Vec<Doc>,
|
doc: Vec<Doc>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, XmlRead)]
|
#[derive(Debug, XmlRead)]
|
||||||
|
|
@ -100,7 +97,6 @@ struct Doc {
|
||||||
kind: Option<String>,
|
kind: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let content = fs::read_to_string("./amqp0-9-1.xml").unwrap();
|
let content = fs::read_to_string("./amqp0-9-1.xml").unwrap();
|
||||||
|
|
||||||
|
|
@ -115,6 +111,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen(amqp: &Amqp) {
|
fn codegen(amqp: &Amqp) {
|
||||||
|
println!("#![allow(dead_code)]");
|
||||||
println!("// This file has been generated by `amqp_codegen`. Do not edit it manually.\n");
|
println!("// This file has been generated by `amqp_codegen`. Do not edit it manually.\n");
|
||||||
codegen_domain_defs(amqp);
|
codegen_domain_defs(amqp);
|
||||||
codegen_class_defs(amqp);
|
codegen_class_defs(amqp);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
// This file has been generated by `amqp_codegen`. Do not edit it manually.
|
// This file has been generated by `amqp_codegen`. Do not edit it manually.
|
||||||
|
|
||||||
pub type ClassId = u16;
|
pub type ClassId = u16;
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ pub fn longstr<W: Write>(value: Longstr, writer: &mut W) -> Result<(), TransErro
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this appears to be unused right now, but it could be used in `Basic` things?
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn timestamp<W: Write>(value: Timestamp, writer: &mut W) -> Result<(), TransError> {
|
pub fn timestamp<W: Write>(value: Timestamp, writer: &mut W) -> Result<(), TransError> {
|
||||||
writer.write_all(&value.to_be_bytes())?;
|
writer.write_all(&value.to_be_bytes())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use std::net::SocketAddr;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info};
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
fn ensure_conn(condition: bool) -> Result<()> {
|
fn ensure_conn(condition: bool) -> Result<()> {
|
||||||
if condition {
|
if condition {
|
||||||
|
|
@ -27,17 +26,15 @@ pub struct Connection {
|
||||||
max_frame_size: usize,
|
max_frame_size: usize,
|
||||||
heartbeat_delay: u16,
|
heartbeat_delay: u16,
|
||||||
channel_max: u16,
|
channel_max: u16,
|
||||||
id: Uuid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
pub fn new(stream: TcpStream, id: Uuid) -> Self {
|
pub fn new(stream: TcpStream) -> Self {
|
||||||
Self {
|
Self {
|
||||||
stream,
|
stream,
|
||||||
max_frame_size: FRAME_SIZE_MIN_MAX,
|
max_frame_size: FRAME_SIZE_MIN_MAX,
|
||||||
heartbeat_delay: HEARTBEAT_DELAY,
|
heartbeat_delay: HEARTBEAT_DELAY,
|
||||||
channel_max: CHANNEL_MAX,
|
channel_max: CHANNEL_MAX,
|
||||||
id,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +193,7 @@ impl Connection {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
debug!(?version, expected_version = ?SUPPORTED_PROTOCOL_VERSION, "Version negotiation failed, unsupported version");
|
debug!(?version, expected_version = ?SUPPORTED_PROTOCOL_VERSION, "Version negotiation failed, unsupported version");
|
||||||
Err(ProtocolError::OtherCloseConnection.into())
|
Err(ProtocolError::CloseNow.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
|
|
||||||
pub type StdResult<T, E> = std::result::Result<T, E>;
|
pub type StdResult<T, E> = std::result::Result<T, E>;
|
||||||
|
|
@ -26,8 +28,10 @@ pub enum ProtocolError {
|
||||||
ConException(#[from] ConException),
|
ConException(#[from] ConException),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
ChannelException(#[from] ChannelException),
|
ChannelException(#[from] ChannelException),
|
||||||
#[error("closing connection")]
|
#[error("Connection must be closed")]
|
||||||
OtherCloseConnection,
|
CloseNow,
|
||||||
|
#[error("Graceful connection closing requested")]
|
||||||
|
GracefulClose,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
|
@ -37,7 +41,7 @@ pub enum ConException {
|
||||||
#[error("503 Command invalid")]
|
#[error("503 Command invalid")]
|
||||||
CommandInvalid,
|
CommandInvalid,
|
||||||
#[error("503 Syntax error | {0:?}")]
|
#[error("503 Syntax error | {0:?}")]
|
||||||
/// A method was received but there was a syntax error. The string stores where it occured.
|
/// A method was received but there was a syntax error. The string stores where it occurred.
|
||||||
SyntaxError(Vec<String>),
|
SyntaxError(Vec<String>),
|
||||||
#[error("504 Channel error")]
|
#[error("504 Channel error")]
|
||||||
ChannelError,
|
ChannelError,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
mod classes;
|
mod classes;
|
||||||
|
|
@ -29,7 +27,7 @@ pub async fn do_thing_i_guess() -> Result<()> {
|
||||||
info!(local_addr = ?stream.local_addr(), %id, "Accepted new connection");
|
info!(local_addr = ?stream.local_addr(), %id, "Accepted new connection");
|
||||||
let span = info_span!("client-connection", %id);
|
let span = info_span!("client-connection", %id);
|
||||||
|
|
||||||
let connection = Connection::new(stream, id);
|
let connection = Connection::new(stream);
|
||||||
|
|
||||||
tokio::spawn(connection.start_connection_processing().instrument(span));
|
tokio::spawn(connection.start_connection_processing().instrument(span));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ async fn main() -> Result<()> {
|
||||||
for arg in env::args().skip(1) {
|
for arg in env::args().skip(1) {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--trace" => level = Level::TRACE,
|
"--trace" => level = Level::TRACE,
|
||||||
|
"ignore-this-clippy" => eprintln!("yes please"),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue