mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 19:55:03 +01:00
formatting!
This commit is contained in:
parent
770762b920
commit
cae9683bd4
33 changed files with 147 additions and 87 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
reorder_imports = true
|
|
||||||
imports_granularity = "Crate"
|
imports_granularity = "Crate"
|
||||||
newline_style = "Unix"
|
newline_style = "Unix"
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,21 @@
|
||||||
use crate::{consumer::Consumer, methods, methods::Method, newtype_id, GlobalData, Queue};
|
|
||||||
use bytes::Bytes;
|
|
||||||
use parking_lot::Mutex;
|
|
||||||
use smallvec::SmallVec;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{Display, Formatter},
|
fmt::{Display, Formatter},
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use bytes::Bytes;
|
||||||
|
use parking_lot::Mutex;
|
||||||
|
use smallvec::SmallVec;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
consumer::Consumer,
|
||||||
|
methods::{self, Method},
|
||||||
|
newtype_id, GlobalData, Queue,
|
||||||
|
};
|
||||||
|
|
||||||
newtype_id!(pub ConnectionId);
|
newtype_id!(pub ConnectionId);
|
||||||
newtype_id!(pub ChannelId);
|
newtype_id!(pub ChannelId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,21 @@ pub mod message;
|
||||||
pub mod methods;
|
pub mod methods;
|
||||||
pub mod queue;
|
pub mod queue;
|
||||||
|
|
||||||
use crate::{
|
|
||||||
connection::{Channel, Connection},
|
|
||||||
queue::{Queue, QueueName},
|
|
||||||
};
|
|
||||||
use connection::{ChannelId, ConnectionId};
|
|
||||||
use parking_lot::Mutex;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use connection::{ChannelId, ConnectionId};
|
||||||
|
use parking_lot::Mutex;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
connection::{Channel, Connection},
|
||||||
|
queue::{Queue, QueueName},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GlobalData {
|
pub struct GlobalData {
|
||||||
inner: Arc<Mutex<GlobalDataInner>>,
|
inner: Arc<Mutex<GlobalDataInner>>,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{connection::ContentHeader, newtype_id};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::sync::Arc;
|
|
||||||
|
use crate::{connection::ContentHeader, newtype_id};
|
||||||
|
|
||||||
pub type Message = Arc<MessageInner>;
|
pub type Message = Arc<MessageInner>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
use crate::{
|
|
||||||
consumer::{Consumer, ConsumerId},
|
|
||||||
message::Message,
|
|
||||||
newtype, newtype_id, ChannelId,
|
|
||||||
};
|
|
||||||
use parking_lot::Mutex;
|
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Borrow,
|
borrow::Borrow,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{Debug, Display, Formatter},
|
fmt::{Debug, Display, Formatter},
|
||||||
sync::{atomic::AtomicUsize, Arc},
|
sync::{atomic::AtomicUsize, Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use parking_lot::Mutex;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
consumer::{Consumer, ConsumerId},
|
||||||
|
message::Message,
|
||||||
|
newtype, newtype_id, ChannelId,
|
||||||
|
};
|
||||||
|
|
||||||
pub type Queue = Arc<QueueInner>;
|
pub type Queue = Arc<QueueInner>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
use anyhow::{ensure, Context, Result};
|
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
fs::File,
|
fs::File,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use anyhow::{ensure, Context, Result};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use zip::{write::FileOptions, ZipWriter};
|
use zip::{write::FileOptions, ZipWriter};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,3 @@
|
||||||
use axum::{
|
|
||||||
body::Body,
|
|
||||||
http::{header, Request, Response, StatusCode},
|
|
||||||
};
|
|
||||||
use mime_guess::mime;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
|
|
@ -11,6 +6,12 @@ use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use axum::{
|
||||||
|
body::Body,
|
||||||
|
http::{header, Request, Response, StatusCode},
|
||||||
|
};
|
||||||
|
use mime_guess::mime;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
mod archive;
|
mod archive;
|
||||||
|
|
||||||
use crate::archive::StaticFileService;
|
|
||||||
use amqp_core::GlobalData;
|
use amqp_core::GlobalData;
|
||||||
use axum::{
|
use axum::{
|
||||||
http::{Method, StatusCode},
|
http::{Method, StatusCode},
|
||||||
|
|
@ -14,6 +13,8 @@ use serde::Serialize;
|
||||||
use tower_http::cors::{Any, CorsLayer};
|
use tower_http::cors::{Any, CorsLayer};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
|
use crate::archive::StaticFileService;
|
||||||
|
|
||||||
const DATA_ZIP: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/frontend.zip"));
|
const DATA_ZIP: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/frontend.zip"));
|
||||||
|
|
||||||
pub async fn start_dashboard(global_data: GlobalData) {
|
pub async fn start_dashboard(global_data: GlobalData) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::Result;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
amqp_todo,
|
amqp_todo,
|
||||||
connection::Channel,
|
connection::Channel,
|
||||||
|
|
@ -6,9 +7,10 @@ use amqp_core::{
|
||||||
error::ChannelException,
|
error::ChannelException,
|
||||||
methods::{BasicConsume, BasicConsumeOk, Method},
|
methods::{BasicConsume, BasicConsumeOk, Method},
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
use crate::Result;
|
||||||
|
|
||||||
pub fn consume(channel: Channel, basic_consume: BasicConsume) -> Result<Method> {
|
pub fn consume(channel: Channel, basic_consume: BasicConsume) -> Result<Method> {
|
||||||
let BasicConsume {
|
let BasicConsume {
|
||||||
queue: queue_name,
|
queue: queue_name,
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ mod consume;
|
||||||
mod publish;
|
mod publish;
|
||||||
mod queue;
|
mod queue;
|
||||||
|
|
||||||
use crate::Result;
|
|
||||||
use amqp_core::{amqp_todo, connection::Channel, message::Message, methods::Method};
|
use amqp_core::{amqp_todo, connection::Channel, message::Message, methods::Method};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
use crate::Result;
|
||||||
|
|
||||||
pub fn handle_basic_publish(channel_handle: Channel, message: Message) -> Result<()> {
|
pub fn handle_basic_publish(channel_handle: Channel, message: Message) -> Result<()> {
|
||||||
publish::publish(channel_handle, message)
|
publish::publish(channel_handle, message)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::Result;
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
amqp_todo,
|
amqp_todo,
|
||||||
connection::Channel,
|
connection::Channel,
|
||||||
|
|
@ -8,6 +7,8 @@ use amqp_core::{
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
|
use crate::Result;
|
||||||
|
|
||||||
pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
|
pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
|
||||||
debug!(?message, "Publishing message");
|
debug!(?message, "Publishing message");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{queue_worker::QueueTask, Result};
|
use std::sync::{atomic::AtomicUsize, Arc};
|
||||||
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
amqp_todo,
|
amqp_todo,
|
||||||
connection::Channel,
|
connection::Channel,
|
||||||
|
|
@ -7,9 +8,10 @@ use amqp_core::{
|
||||||
GlobalData,
|
GlobalData,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::{atomic::AtomicUsize, Arc};
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
use crate::{queue_worker::QueueTask, Result};
|
||||||
|
|
||||||
pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method> {
|
pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method> {
|
||||||
let QueueDeclare {
|
let QueueDeclare {
|
||||||
queue: queue_name,
|
queue: queue_name,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
connection::ConnectionEvent,
|
connection::ConnectionEvent,
|
||||||
consumer::Consumer,
|
consumer::Consumer,
|
||||||
|
|
@ -6,7 +8,6 @@ use amqp_core::{
|
||||||
queue::{Queue, QueueEvent, QueueEventReceiver},
|
queue::{Queue, QueueEvent, QueueEventReceiver},
|
||||||
GlobalData,
|
GlobalData,
|
||||||
};
|
};
|
||||||
use std::borrow::Borrow;
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
use amqp_core::methods::Method;
|
use amqp_core::methods::Method;
|
||||||
use amqp_transport::methods::{self, RandomMethod};
|
use amqp_transport::methods::{
|
||||||
|
RandomMethod, {self},
|
||||||
|
};
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
use crate::{
|
use std::{
|
||||||
error::{ConException, ProtocolError, Result, TransError},
|
cmp::Ordering, collections::HashMap, net::SocketAddr, pin::Pin, sync::Arc, time::Duration,
|
||||||
frame,
|
|
||||||
frame::{parse_content_header, Frame, FrameType, MaxFrameSize},
|
|
||||||
methods, sasl,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
connection::{
|
connection::{
|
||||||
Channel, ChannelInner, ChannelNum, ConEventReceiver, ConEventSender, Connection,
|
Channel, ChannelInner, ChannelNum, ConEventReceiver, ConEventSender, Connection,
|
||||||
|
|
@ -20,9 +18,6 @@ use amqp_core::{
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
|
||||||
cmp::Ordering, collections::HashMap, net::SocketAddr, pin::Pin, sync::Arc, time::Duration,
|
|
||||||
};
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::{AsyncReadExt, AsyncWriteExt},
|
io::{AsyncReadExt, AsyncWriteExt},
|
||||||
net::TcpStream,
|
net::TcpStream,
|
||||||
|
|
@ -30,6 +25,12 @@ use tokio::{
|
||||||
};
|
};
|
||||||
use tracing::{debug, error, info, trace, warn};
|
use tracing::{debug, error, info, trace, warn};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
error::{ConException, ProtocolError, Result, TransError},
|
||||||
|
frame::{self, parse_content_header, Frame, FrameType, MaxFrameSize},
|
||||||
|
methods, sasl,
|
||||||
|
};
|
||||||
|
|
||||||
fn ensure_conn(condition: bool) -> Result<()> {
|
fn ensure_conn(condition: bool) -> Result<()> {
|
||||||
if condition {
|
if condition {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
use crate::error::{ConException, ProtocolError, Result};
|
|
||||||
use amqp_core::connection::{ChannelNum, ContentHeader};
|
|
||||||
use anyhow::Context;
|
|
||||||
use bytes::Bytes;
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
num::NonZeroUsize,
|
num::NonZeroUsize,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use amqp_core::connection::{ChannelNum, ContentHeader};
|
||||||
|
use anyhow::Context;
|
||||||
|
use bytes::Bytes;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
|
use crate::error::{ConException, ProtocolError, Result};
|
||||||
|
|
||||||
const REQUIRED_FRAME_END: u8 = 0xCE;
|
const REQUIRED_FRAME_END: u8 = 0xCE;
|
||||||
|
|
||||||
mod frame_type {
|
mod frame_type {
|
||||||
|
|
@ -37,20 +39,23 @@ pub enum FrameType {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod content_header_parse {
|
mod content_header_parse {
|
||||||
use crate::{
|
|
||||||
error::TransError,
|
|
||||||
methods::parse_helper::{octet, shortstr, table, timestamp},
|
|
||||||
};
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
connection::ContentHeader,
|
connection::ContentHeader,
|
||||||
methods,
|
methods::{
|
||||||
methods::FieldValue::{FieldTable, ShortShortUInt, ShortString, Timestamp},
|
self,
|
||||||
|
FieldValue::{FieldTable, ShortShortUInt, ShortString, Timestamp},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use nom::number::{
|
use nom::number::{
|
||||||
complete::{u16, u64},
|
complete::{u16, u64},
|
||||||
Endianness::Big,
|
Endianness::Big,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
error::TransError,
|
||||||
|
methods::parse_helper::{octet, shortstr, table, timestamp},
|
||||||
|
};
|
||||||
|
|
||||||
type IResult<'a, T> = nom::IResult<&'a [u8], T, TransError>;
|
type IResult<'a, T> = nom::IResult<&'a [u8], T, TransError>;
|
||||||
|
|
||||||
pub fn basic_properties(flags: u16, input: &[u8]) -> IResult<'_, methods::Table> {
|
pub fn basic_properties(flags: u16, input: &[u8]) -> IResult<'_, methods::Table> {
|
||||||
|
|
@ -133,10 +138,8 @@ pub fn parse_content_header(input: &[u8]) -> Result<ContentHeader> {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod content_header_write {
|
mod content_header_write {
|
||||||
use crate::{
|
use std::io::Write;
|
||||||
error::Result,
|
|
||||||
methods::write_helper::{longlong, octet, short, shortstr, table, timestamp},
|
|
||||||
};
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
connection::ContentHeader,
|
connection::ContentHeader,
|
||||||
methods::{
|
methods::{
|
||||||
|
|
@ -144,7 +147,11 @@ mod content_header_write {
|
||||||
Table,
|
Table,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::io::Write;
|
|
||||||
|
use crate::{
|
||||||
|
error::Result,
|
||||||
|
methods::write_helper::{longlong, octet, short, shortstr, table, timestamp},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn write_content_header<W: Write>(buf: &mut W, header: &ContentHeader) -> Result<()> {
|
pub fn write_content_header<W: Write>(buf: &mut W, header: &ContentHeader) -> Result<()> {
|
||||||
short(&header.class_id, buf)?;
|
short(&header.class_id, buf)?;
|
||||||
|
|
@ -325,9 +332,10 @@ fn parse_frame_type(kind: u8, channel: ChannelNum) -> Result<FrameType> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::frame::{ChannelNum, Frame, FrameType, MaxFrameSize};
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
||||||
|
use crate::frame::{ChannelNum, Frame, FrameType, MaxFrameSize};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn read_small_body() {
|
async fn read_small_body() {
|
||||||
let mut bytes: &[u8] = &[
|
let mut bytes: &[u8] = &[
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,15 @@ mod tests;
|
||||||
|
|
||||||
// TODO: handle big types
|
// TODO: handle big types
|
||||||
|
|
||||||
use crate::connection::TransportConnection;
|
use std::{future::Future, net::SocketAddr};
|
||||||
|
|
||||||
use amqp_core::{connection::ConnectionEvent, queue::QueueEvent, GlobalData};
|
use amqp_core::{connection::ConnectionEvent, queue::QueueEvent, GlobalData};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use std::{future::Future, net::SocketAddr};
|
|
||||||
use tokio::{net, net::TcpStream, select};
|
use tokio::{net, net::TcpStream, select};
|
||||||
use tracing::{info, info_span, Instrument};
|
use tracing::{info, info_span, Instrument};
|
||||||
|
|
||||||
|
use crate::connection::TransportConnection;
|
||||||
|
|
||||||
pub async fn do_thing_i_guess(
|
pub async fn do_thing_i_guess(
|
||||||
global_data: GlobalData,
|
global_data: GlobalData,
|
||||||
terminate: impl Future + Send,
|
terminate: impl Future + Send,
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@
|
||||||
// This file has been generated by `xtask/src/codegen`. Do not edit it manually.
|
// This file has been generated by `xtask/src/codegen`. Do not edit it manually.
|
||||||
|
|
||||||
pub mod parse {
|
pub mod parse {
|
||||||
use crate::{error::TransError, methods::parse_helper::*};
|
|
||||||
use amqp_core::methods::*;
|
use amqp_core::methods::*;
|
||||||
use nom::{branch::alt, bytes::complete::tag};
|
use nom::{branch::alt, bytes::complete::tag};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
use crate::{error::TransError, methods::parse_helper::*};
|
||||||
|
|
||||||
pub type IResult<'a, T> = nom::IResult<&'a [u8], T, TransError>;
|
pub type IResult<'a, T> = nom::IResult<&'a [u8], T, TransError>;
|
||||||
|
|
||||||
pub fn parse_method(input: &[u8]) -> Result<(&[u8], Method), nom::Err<TransError>> {
|
pub fn parse_method(input: &[u8]) -> Result<(&[u8], Method), nom::Err<TransError>> {
|
||||||
|
|
@ -886,10 +887,12 @@ pub mod parse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub mod write {
|
pub mod write {
|
||||||
use crate::{error::TransError, methods::write_helper::*};
|
|
||||||
use amqp_core::methods::*;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
use amqp_core::methods::*;
|
||||||
|
|
||||||
|
use crate::{error::TransError, methods::write_helper::*};
|
||||||
|
|
||||||
pub fn write_method<W: Write>(method: &Method, mut writer: W) -> Result<(), TransError> {
|
pub fn write_method<W: Write>(method: &Method, mut writer: W) -> Result<(), TransError> {
|
||||||
match method {
|
match method {
|
||||||
Method::ConnectionStart(ConnectionStart {
|
Method::ConnectionStart(ConnectionStart {
|
||||||
|
|
@ -1303,10 +1306,11 @@ pub mod write {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod random {
|
mod random {
|
||||||
use crate::methods::RandomMethod;
|
|
||||||
use amqp_core::methods::*;
|
use amqp_core::methods::*;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
|
use crate::methods::RandomMethod;
|
||||||
|
|
||||||
impl<R: Rng> RandomMethod<R> for Method {
|
impl<R: Rng> RandomMethod<R> for Method {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn random(rng: &mut R) -> Self {
|
fn random(rng: &mut R) -> Self {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
use crate::error::TransError;
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
error::ConException,
|
error::ConException,
|
||||||
methods::{FieldValue, Method, Table},
|
methods::{FieldValue, Method, Table},
|
||||||
};
|
};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
|
use crate::error::TransError;
|
||||||
|
|
||||||
mod generated;
|
mod generated;
|
||||||
pub mod parse_helper;
|
pub mod parse_helper;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::{error::TransError, methods::generated::parse::IResult};
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
error::{ConException, ProtocolError},
|
error::{ConException, ProtocolError},
|
||||||
methods::{
|
methods::{
|
||||||
|
|
@ -18,6 +17,8 @@ use nom::{
|
||||||
Err,
|
Err,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{error::TransError, methods::generated::parse::IResult};
|
||||||
|
|
||||||
impl<T> nom::error::ParseError<T> for TransError {
|
impl<T> nom::error::ParseError<T> for TransError {
|
||||||
fn from_error_kind(_input: T, _kind: ErrorKind) -> Self {
|
fn from_error_kind(_input: T, _kind: ErrorKind) -> Self {
|
||||||
ConException::SyntaxError(vec![]).into()
|
ConException::SyntaxError(vec![]).into()
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
// create random methods to test the ser/de code together. if they diverge, we have a bug
|
// create random methods to test the ser/de code together. if they diverge, we have a bug
|
||||||
// this is not perfect, if they both have the same bug it won't be found, but that's an ok tradeoff
|
// this is not perfect, if they both have the same bug it won't be found, but that's an ok tradeoff
|
||||||
|
|
||||||
use crate::methods::{FieldValue, Method, RandomMethod};
|
|
||||||
use rand::SeedableRng;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use rand::SeedableRng;
|
||||||
|
|
||||||
|
use crate::methods::{FieldValue, Method, RandomMethod};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pack_few_bits() {
|
fn pack_few_bits() {
|
||||||
let bits = [true, false, true];
|
let bits = [true, false, true];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{error::TransError, methods::FieldValue};
|
use std::io::Write;
|
||||||
|
|
||||||
use amqp_core::methods::{Bit, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, Timestamp};
|
use amqp_core::methods::{Bit, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, Timestamp};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use std::io::Write;
|
|
||||||
|
use crate::{error::TransError, methods::FieldValue};
|
||||||
|
|
||||||
pub fn octet<W: Write>(value: &Octet, writer: &mut W) -> Result<(), TransError> {
|
pub fn octet<W: Write>(value: &Octet, writer: &mut W) -> Result<(), TransError> {
|
||||||
writer.write_all(&[*value])?;
|
writer.write_all(&[*value])?;
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
//!
|
//!
|
||||||
//! Currently only supports PLAIN (see [RFC 4616](https://datatracker.ietf.org/doc/html/rfc4616))
|
//! Currently only supports PLAIN (see [RFC 4616](https://datatracker.ietf.org/doc/html/rfc4616))
|
||||||
|
|
||||||
use crate::error::Result;
|
|
||||||
use amqp_core::error::ConException;
|
use amqp_core::error::ConException;
|
||||||
|
|
||||||
|
use crate::error::Result;
|
||||||
|
|
||||||
pub struct PlainUser {
|
pub struct PlainUser {
|
||||||
pub authorization_identity: String,
|
pub authorization_identity: String,
|
||||||
pub authentication_identity: String,
|
pub authentication_identity: String,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
use crate::{frame, frame::FrameType, methods};
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use amqp_core::{
|
use amqp_core::{
|
||||||
connection::ChannelNum,
|
connection::ChannelNum,
|
||||||
methods::{ConnectionStart, ConnectionStartOk, FieldValue, Method},
|
methods::{ConnectionStart, ConnectionStartOk, FieldValue, Method},
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
|
||||||
|
use crate::{frame, frame::FrameType, methods};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn write_start_ok_frame() {
|
async fn write_start_ok_frame() {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::str::FromStr;
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{project_root, yarn_install};
|
|
||||||
use anyhow::ensure;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
use anyhow::ensure;
|
||||||
|
|
||||||
|
use crate::{project_root, yarn_install};
|
||||||
|
|
||||||
pub fn main() -> anyhow::Result<()> {
|
pub fn main() -> anyhow::Result<()> {
|
||||||
println!("$ cargo fmt --check");
|
println!("$ cargo fmt --check");
|
||||||
let status = Command::new("cargo")
|
let status = Command::new("cargo")
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ mod parser;
|
||||||
mod random;
|
mod random;
|
||||||
mod write;
|
mod write;
|
||||||
|
|
||||||
use anyhow::{bail, Context};
|
|
||||||
use heck::ToUpperCamelCase;
|
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
fs::File,
|
fs::File,
|
||||||
|
|
@ -15,6 +13,9 @@ use std::{
|
||||||
process::Command,
|
process::Command,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use anyhow::{bail, Context};
|
||||||
|
use heck::ToUpperCamelCase;
|
||||||
use strong_xml::XmlRead;
|
use strong_xml::XmlRead;
|
||||||
|
|
||||||
#[derive(Debug, XmlRead)]
|
#[derive(Debug, XmlRead)]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
use super::{Amqp, Assert, Class, Domain, Method};
|
|
||||||
use crate::codegen::Codegen;
|
|
||||||
use heck::{ToSnakeCase, ToUpperCamelCase};
|
use heck::{ToSnakeCase, ToUpperCamelCase};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
use super::{Amqp, Assert, Class, Domain, Method};
|
||||||
|
use crate::codegen::Codegen;
|
||||||
|
|
||||||
fn method_function_name(class_name: &str) -> impl Fn(&Method) -> String + '_ {
|
fn method_function_name(class_name: &str) -> impl Fn(&Method) -> String + '_ {
|
||||||
move |method| {
|
move |method| {
|
||||||
let method_name = method.name.to_snake_case();
|
let method_name = method.name.to_snake_case();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::codegen::{Amqp, Codegen};
|
|
||||||
use heck::ToUpperCamelCase;
|
use heck::ToUpperCamelCase;
|
||||||
|
|
||||||
|
use crate::codegen::{Amqp, Codegen};
|
||||||
|
|
||||||
impl Codegen {
|
impl Codegen {
|
||||||
pub fn codegen_random(&mut self, amqp: &Amqp) {
|
pub fn codegen_random(&mut self, amqp: &Amqp) {
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::codegen::{Amqp, Codegen};
|
|
||||||
use heck::ToUpperCamelCase;
|
use heck::ToUpperCamelCase;
|
||||||
|
|
||||||
|
use crate::codegen::{Amqp, Codegen};
|
||||||
|
|
||||||
impl Codegen {
|
impl Codegen {
|
||||||
pub fn codegen_write(&mut self, amqp: &Amqp) {
|
pub fn codegen_write(&mut self, amqp: &Amqp) {
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{project_root, yarn_install};
|
|
||||||
use anyhow::ensure;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
use anyhow::ensure;
|
||||||
|
|
||||||
|
use crate::{project_root, yarn_install};
|
||||||
|
|
||||||
pub fn main() -> anyhow::Result<()> {
|
pub fn main() -> anyhow::Result<()> {
|
||||||
println!("$ cargo fmt");
|
println!("$ cargo fmt");
|
||||||
let status = Command::new("cargo")
|
let status = Command::new("cargo")
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
use anyhow::{ensure, Context, Result};
|
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use anyhow::{ensure, Context, Result};
|
||||||
|
|
||||||
mod check_fmt;
|
mod check_fmt;
|
||||||
mod codegen;
|
mod codegen;
|
||||||
mod fmt;
|
mod fmt;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{project_root, yarn_install};
|
|
||||||
use anyhow::{ensure, Context, Result};
|
|
||||||
use std::{path::Path, process::Command, thread::sleep, time::Duration};
|
use std::{path::Path, process::Command, thread::sleep, time::Duration};
|
||||||
|
|
||||||
|
use anyhow::{ensure, Context, Result};
|
||||||
|
|
||||||
|
use crate::{project_root, yarn_install};
|
||||||
|
|
||||||
pub fn main() -> Result<()> {
|
pub fn main() -> Result<()> {
|
||||||
let project_root = project_root();
|
let project_root = project_root();
|
||||||
let test_js_root = project_root.join("test-js");
|
let test_js_root = project_root.join("test-js");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue