Skip to content

Commit 129fbfe

Browse files
author
Zane Othman
authored
Move protocol module to separate crate in workspace (#6)
1 parent e107d13 commit 129fbfe

File tree

22 files changed

+59
-60
lines changed

22 files changed

+59
-60
lines changed

Cargo.toml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
[package]
2-
name = "tacacs-plus"
3-
version = "0.1.0"
4-
edition = "2021"
5-
6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
8-
[features]
9-
default = ["std"]
10-
std = ["byteorder/std", "num_enum/std", "md-5/std"]
11-
docsrs = []
12-
13-
[dependencies]
14-
bitflags = { version = "2.4.2" }
15-
byteorder = { version = "1.5.0", default-features = false }
16-
num_enum = { version = "0.7.2", default-features = false }
17-
getset = { version = "0.1.2" }
18-
md-5 = { version = "0.10.6", default-features = false }
19-
20-
[dev-dependencies]
21-
tinyvec = { version = "1.6.1", features = ["rustc_1_57"] }
1+
[workspace]
2+
members = ["tacacs-plus-protocol"]
3+
resolver = "2"

src/lib.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tacacs-plus-protocol/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "tacacs-plus-protocol"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[features]
9+
default = ["std"]
10+
std = ["byteorder/std", "num_enum/std", "md-5/std"]
11+
12+
[dependencies]
13+
bitflags = { version = "2.4.2" }
14+
byteorder = { version = "1.5.0", default-features = false }
15+
num_enum = { version = "0.7.2", default-features = false }
16+
getset = { version = "0.1.2" }
17+
md-5 = { version = "0.10.6", default-features = false }
18+
19+
[dev-dependencies]
20+
tinyvec = { version = "1.6.1", features = ["rustc_1_57"] }
File renamed without changes.

src/protocol/accounting/owned.rs renamed to tacacs-plus-protocol/src/accounting/owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::ToOwned;
22
use std::string::String;
33

44
use super::{Reply, Status};
5-
use crate::protocol::ToOwnedBody;
5+
use crate::ToOwnedBody;
66

77
/// An owned version of a [`Reply`](super::Reply).
88
// TODO: stop ignoring dead_code lint when fields are actually used in client

src/protocol/accounting/tests.rs renamed to tacacs-plus-protocol/src/accounting/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use super::*;
2-
use crate::protocol::packet::xor_body_with_pad;
3-
use crate::protocol::{
2+
use crate::packet::xor_body_with_pad;
3+
use crate::FieldText;
4+
use crate::{
45
Argument, AuthenticationContext, AuthenticationMethod, AuthenticationService,
56
AuthenticationType, HeaderInfo, MajorVersion, MinorVersion, Packet, PacketFlags,
67
PrivilegeLevel, UserInformation, Version,
78
};
8-
use crate::FieldText;
99

1010
use tinyvec::array_vec;
1111

File renamed without changes.

src/protocol/authentication/owned.rs renamed to tacacs-plus-protocol/src/authentication/owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::ToOwned;
22
use std::string::String;
33
use std::vec::Vec;
44

5-
use crate::protocol::ToOwnedBody;
5+
use crate::ToOwnedBody;
66

77
use super::Reply;
88
use super::{ReplyFlags, Status};

src/protocol/authentication/tests.rs renamed to tacacs-plus-protocol/src/authentication/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::*;
2-
use crate::protocol::{
2+
use crate::FieldText;
3+
use crate::{
34
AuthenticationContext, AuthenticationService, AuthenticationType, HeaderInfo, MajorVersion,
45
MinorVersion, Packet, PacketFlags, PrivilegeLevel, UserInformation, Version,
56
};
6-
use crate::FieldText;
77

88
use tinyvec::array_vec;
99

src/protocol/authorization/owned.rs renamed to tacacs-plus-protocol/src/authorization/owned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::vec::Vec;
44

55
use super::Reply;
66
use super::Status;
7-
use crate::protocol::ArgumentOwned;
8-
use crate::protocol::ToOwnedBody;
7+
use crate::ArgumentOwned;
8+
use crate::ToOwnedBody;
99

1010
/// An authorization reply packet with owned fields.
1111
// TODO: stop ignoring dead_code lint when fields are actually used

src/protocol/authorization/tests.rs renamed to tacacs-plus-protocol/src/authorization/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use super::*;
2-
use crate::protocol::packet::xor_body_with_pad;
3-
use crate::protocol::{
2+
use crate::packet::xor_body_with_pad;
3+
use crate::FieldText;
4+
use crate::{
45
Arguments, AuthenticationContext, AuthenticationMethod, AuthenticationService,
56
AuthenticationType, HeaderInfo, MajorVersion, MinorVersion, Packet, PacketFlags,
67
PrivilegeLevel, Serialize, UserInformation, Version,
78
};
8-
use crate::FieldText;
99

1010
use tinyvec::array_vec;
1111

@@ -443,7 +443,7 @@ fn full_unobfuscated_reply_packet_to_owned() {
443443
use std::string::String;
444444
use std::vec;
445445

446-
use crate::protocol::ArgumentOwned;
446+
use crate::ArgumentOwned;
447447

448448
let mut raw_packet = array_vec!([u8; 60] =>
449449
// HEADER

src/protocol/fields.rs renamed to tacacs-plus-protocol/src/fields.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::protocol::MinorVersion;
21
use crate::FieldText;
2+
use crate::MinorVersion;
33

44
use super::SerializeError;
55

@@ -59,7 +59,7 @@ impl PrivilegeLevel {
5959
///
6060
/// # Examples
6161
/// ```
62-
/// use tacacs_plus::protocol::PrivilegeLevel;
62+
/// use tacacs_plus_protocol::PrivilegeLevel;
6363
///
6464
/// let valid_level = PrivilegeLevel::new(3);
6565
/// assert!(valid_level.is_some());

src/protocol.rs renamed to tacacs-plus-protocol/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
//! TACACS+ protocol packet <-> binary format conversions.
1+
//! # tacacs-plus-protocol
2+
//!
3+
//! Serialization & deserialization of (RFC8907) TACACS+ protocol packets.
4+
5+
#![no_std]
6+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
7+
#![warn(missing_docs)]
8+
#![warn(clippy::cast_lossless)]
9+
#![warn(clippy::cast_possible_truncation)]
10+
11+
#[cfg(feature = "std")]
12+
extern crate std;
213

314
use core::{fmt, num::TryFromIntError};
415

@@ -19,6 +30,9 @@ pub use arguments::ArgumentOwned;
1930
mod fields;
2031
pub use fields::*;
2132

33+
mod text;
34+
pub use text::FieldText;
35+
2236
/// An error that occurred when serializing a packet or any of its components into their binary format.
2337
#[non_exhaustive]
2438
#[derive(Debug, PartialEq, Eq)]
File renamed without changes.

src/protocol/packet/header.rs renamed to tacacs-plus-protocol/src/packet/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use byteorder::{ByteOrder, NetworkEndian};
22
use getset::{CopyGetters, MutGetters};
33

44
use super::{PacketFlags, PacketType};
5-
use crate::protocol::{DeserializeError, SerializeError, Version};
5+
use crate::{DeserializeError, SerializeError, Version};
66

77
/// Information included in a TACACS+ packet header.
88
#[derive(PartialEq, Eq, Debug, Clone, CopyGetters, MutGetters)]
@@ -26,7 +26,7 @@ pub struct HeaderInfo {
2626

2727
impl HeaderInfo {
2828
/// Size of a full TACACS+ packet header.
29-
pub(in crate::protocol) const HEADER_SIZE_BYTES: usize = 12;
29+
pub const HEADER_SIZE_BYTES: usize = 12;
3030

3131
/// Bundles some information to be put in the header of a TACACS+ packet.
3232
pub fn new(version: Version, sequence_number: u8, flags: PacketFlags, session_id: u32) -> Self {

src/protocol/packet/tests.rs renamed to tacacs-plus-protocol/src/packet/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22

3-
use crate::protocol::accounting::Reply;
4-
use crate::protocol::{MajorVersion, MinorVersion, Version};
3+
use crate::accounting::Reply;
4+
use crate::{MajorVersion, MinorVersion, Version};
55

66
#[test]
77
fn obfuscated_packet_wrong_unencrypted_flag() {

src/text.rs renamed to tacacs-plus-protocol/src/text.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::fmt;
1313
/// Conversions from `&str`:
1414
///
1515
/// ```
16-
/// use tacacs_plus::FieldText;
16+
/// use tacacs_plus_protocol::FieldText;
1717
///
1818
/// let valid_ascii = "a string";
1919
/// assert!(FieldText::try_from(valid_ascii).is_ok());
@@ -25,7 +25,7 @@ use core::fmt;
2525
/// Conversions from `&[u8]`:
2626
///
2727
/// ```
28-
/// use tacacs_plus::FieldText;
28+
/// use tacacs_plus_protocol::FieldText;
2929
///
3030
/// let valid_slice = b"this is (almost) a string";
3131
/// assert!(FieldText::try_from(valid_slice.as_slice()).is_ok());

0 commit comments

Comments
 (0)