mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 11:45:02 +01:00
rename classes to methods
This commit is contained in:
parent
9b48dec533
commit
7ce8f8058d
8 changed files with 26 additions and 26 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::classes::Method;
|
||||
use crate::error::{ConException, ProtocolError, Result};
|
||||
use crate::frame::{Frame, FrameType};
|
||||
use crate::{classes, frame, sasl};
|
||||
use crate::methods::Method;
|
||||
use crate::{frame, methods, sasl};
|
||||
use amqp_core::GlobalData;
|
||||
use anyhow::Context;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -90,7 +90,7 @@ impl Connection {
|
|||
|
||||
async fn send_method(&mut self, channel: u16, method: Method) -> Result<()> {
|
||||
let mut payload = Vec::with_capacity(64);
|
||||
classes::write::write_method(method, &mut payload)?;
|
||||
methods::write::write_method(method, &mut payload)?;
|
||||
frame::write_frame(
|
||||
&Frame {
|
||||
kind: FrameType::Method,
|
||||
|
|
@ -107,7 +107,7 @@ impl Connection {
|
|||
|
||||
ensure_conn(start_ok_frame.kind == FrameType::Method)?;
|
||||
|
||||
let class = classes::parse_method(&start_ok_frame.payload)?;
|
||||
let class = methods::parse_method(&start_ok_frame.payload)?;
|
||||
Ok(class)
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ impl Connection {
|
|||
}
|
||||
|
||||
async fn dispatch_method(&mut self, frame: Frame) -> Result<()> {
|
||||
let method = classes::parse_method(&frame.payload)?;
|
||||
let method = methods::parse_method(&frame.payload)?;
|
||||
debug!(?method, "Received method");
|
||||
|
||||
match method {
|
||||
|
|
@ -326,9 +326,9 @@ impl Drop for Channel {
|
|||
}
|
||||
}
|
||||
|
||||
fn server_properties(host: SocketAddr) -> classes::Table {
|
||||
fn ls(str: &str) -> classes::FieldValue {
|
||||
classes::FieldValue::LongString(str.into())
|
||||
fn server_properties(host: SocketAddr) -> methods::Table {
|
||||
fn ls(str: &str) -> methods::FieldValue {
|
||||
methods::FieldValue::LongString(str.into())
|
||||
}
|
||||
|
||||
let host_str = host.ip().to_string();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#![warn(rust_2018_idioms)]
|
||||
|
||||
mod classes;
|
||||
mod connection;
|
||||
mod error;
|
||||
mod frame;
|
||||
mod methods;
|
||||
mod sasl;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
|
|
|||
|
|
@ -787,8 +787,8 @@ pub enum Method {
|
|||
|
||||
pub mod parse {
|
||||
use super::*;
|
||||
use crate::classes::parse_helper::*;
|
||||
use crate::error::TransError;
|
||||
use crate::methods::parse_helper::*;
|
||||
use nom::{branch::alt, bytes::complete::tag};
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
|
@ -1843,8 +1843,8 @@ pub mod parse {
|
|||
}
|
||||
pub mod write {
|
||||
use super::*;
|
||||
use crate::classes::write_helper::*;
|
||||
use crate::error::TransError;
|
||||
use crate::methods::write_helper::*;
|
||||
use std::io::Write;
|
||||
|
||||
pub fn write_method<W: Write>(class: Method, mut writer: W) -> Result<(), TransError> {
|
||||
|
|
@ -2261,7 +2261,7 @@ pub mod write {
|
|||
#[cfg(test)]
|
||||
mod random {
|
||||
use super::*;
|
||||
use crate::classes::tests::RandomMethod;
|
||||
use crate::methods::tests::RandomMethod;
|
||||
use rand::Rng;
|
||||
|
||||
impl<R: Rng> RandomMethod<R> for Method {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::classes::generated::parse::IResult;
|
||||
use crate::classes::generated::{
|
||||
use crate::error::{ConException, ProtocolError, TransError};
|
||||
use crate::methods::generated::parse::IResult;
|
||||
use crate::methods::generated::{
|
||||
Bit, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, Timestamp,
|
||||
};
|
||||
use crate::error::{ConException, ProtocolError, TransError};
|
||||
use nom::branch::alt;
|
||||
use nom::bytes::complete::{tag, take};
|
||||
use nom::error::ErrorKind;
|
||||
|
|
@ -73,7 +73,7 @@ macro_rules! fail {
|
|||
};
|
||||
}
|
||||
|
||||
use crate::classes::{FieldValue, TableFieldName};
|
||||
use crate::methods::{FieldValue, TableFieldName};
|
||||
pub use fail;
|
||||
|
||||
pub fn octet(input: &[u8]) -> IResult<'_, Octet> {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// 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 tha's an ok tradeoff
|
||||
|
||||
use crate::classes::{FieldValue, Method};
|
||||
use crate::methods::{FieldValue, Method};
|
||||
use rand::{Rng, SeedableRng};
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -138,10 +138,10 @@ fn nested_table() {
|
|||
eprintln!("{table:?}");
|
||||
|
||||
let mut bytes = Vec::new();
|
||||
crate::classes::write_helper::table(table.clone(), &mut bytes).unwrap();
|
||||
crate::methods::write_helper::table(table.clone(), &mut bytes).unwrap();
|
||||
eprintln!("{bytes:?}");
|
||||
|
||||
let (rest, parsed_table) = crate::classes::parse_helper::table(&bytes).unwrap();
|
||||
let (rest, parsed_table) = crate::methods::parse_helper::table(&bytes).unwrap();
|
||||
|
||||
assert!(rest.is_empty());
|
||||
assert_eq!(table, parsed_table);
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::classes::generated::{
|
||||
use crate::error::TransError;
|
||||
use crate::methods::generated::{
|
||||
Bit, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, Timestamp,
|
||||
};
|
||||
use crate::classes::FieldValue;
|
||||
use crate::error::TransError;
|
||||
use crate::methods::FieldValue;
|
||||
use anyhow::Context;
|
||||
use std::io::Write;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::classes::{FieldValue, Method};
|
||||
use crate::frame::FrameType;
|
||||
use crate::{classes, frame};
|
||||
use crate::methods::{FieldValue, Method};
|
||||
use crate::{frame, methods};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[tokio::test]
|
||||
|
|
@ -17,7 +17,7 @@ async fn write_start_ok_frame() {
|
|||
locales: "en_US".into(),
|
||||
};
|
||||
|
||||
classes::write::write_method(method, &mut payload).unwrap();
|
||||
methods::write::write_method(method, &mut payload).unwrap();
|
||||
|
||||
let frame = frame::Frame {
|
||||
kind: FrameType::Method,
|
||||
|
|
@ -136,7 +136,7 @@ fn read_start_ok_payload() {
|
|||
5, 101, 110, 95, 85, 83,
|
||||
];
|
||||
|
||||
let method = classes::parse_method(&raw_data).unwrap();
|
||||
let method = methods::parse_method(&raw_data).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
method,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue