Skip to content

Commit 243ba85

Browse files
tsitsiridakisiosifyordis
authored andcommitted
yordis request
Signed-off-by: itsitsiridakis <iosif.tsitsiridakis@fanatics.live>
1 parent 689aba5 commit 243ba85

8 files changed

Lines changed: 151 additions & 242 deletions

File tree

rsworkspace/crates/acp-nats/src/acp_prefix.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
//! malformed dots (consecutive, leading, trailing). Max 128 bytes. Validity is guaranteed at
88
//! construction.
99
10-
use crate::nats_token_policies::MultiTokenPolicy;
1110
use crate::subject_token_violation::SubjectTokenViolation;
12-
use trogon_nats::NatsToken;
11+
use trogon_nats::DottedNatsToken;
1312

1413
/// Error returned when [`AcpPrefix`] validation fails.
1514
#[derive(Debug, Clone, PartialEq)]
@@ -33,12 +32,12 @@ impl std::error::Error for AcpPrefixError {}
3332

3433
/// NATS-safe ACP prefix. Guarantees validity at construction—invalid instances are unrepresentable.
3534
#[derive(Clone, Debug)]
36-
pub struct AcpPrefix(NatsToken<MultiTokenPolicy>);
35+
pub struct AcpPrefix(DottedNatsToken);
3736

3837
impl AcpPrefix {
3938
pub fn new(s: impl Into<String>) -> Result<Self, AcpPrefixError> {
4039
let s = s.into();
41-
NatsToken::new(s).map(Self).map_err(AcpPrefixError)
40+
DottedNatsToken::new(s).map(Self).map_err(AcpPrefixError)
4241
}
4342

4443
pub fn as_str(&self) -> &str {

rsworkspace/crates/acp-nats/src/constants.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ pub const SESSION_READY_DELAY: Duration = Duration::from_millis(100);
1919
pub const PROMPT_TIMEOUT_WARNING_SUPPRESSION_WINDOW: Duration = Duration::from_secs(5);
2020
pub const TEST_PROMPT_TIMEOUT: Duration = Duration::from_secs(5);
2121

22-
pub const MAX_PREFIX_LENGTH: usize = 128;
23-
pub const MAX_SESSION_ID_LENGTH: usize = 128;
24-
pub const MAX_METHOD_NAME_LENGTH: usize = 128;
25-
2622
pub const AGENT_UNAVAILABLE: i32 = -32001;
2723

2824
pub const SESSION_PREFIX: &str = ".session.";

rsworkspace/crates/acp-nats/src/ext_method_name.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
//! rejects `*`, `>`, whitespace; allows dotted namespaces (e.g. `vendor.operation`) but rejects
66
//! malformed dots (consecutive, leading, trailing). Validity is guaranteed at construction.
77
8-
use crate::nats_token_policies::MultiTokenPolicy;
98
use crate::subject_token_violation::SubjectTokenViolation;
10-
use trogon_nats::NatsToken;
9+
use trogon_nats::DottedNatsToken;
1110

1211
/// Error returned when [`ExtMethodName`] validation fails.
1312
#[derive(Debug, Clone, PartialEq)]
@@ -33,11 +32,13 @@ impl std::error::Error for ExtMethodNameError {}
3332
///
3433
/// Rejects empty, too-long, wildcard, whitespace, and malformed dotted names.
3534
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
36-
pub struct ExtMethodName(NatsToken<MultiTokenPolicy>);
35+
pub struct ExtMethodName(DottedNatsToken);
3736

3837
impl ExtMethodName {
3938
pub fn new(method: impl AsRef<str>) -> Result<Self, ExtMethodNameError> {
40-
NatsToken::new(method).map(Self).map_err(ExtMethodNameError)
39+
DottedNatsToken::new(method)
40+
.map(Self)
41+
.map_err(ExtMethodNameError)
4142
}
4243

4344
pub fn as_str(&self) -> &str {

rsworkspace/crates/acp-nats/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub(crate) mod in_flight_slot_guard;
1010
pub mod jetstream;
1111
pub(crate) mod jsonrpc;
1212
pub mod nats;
13-
pub(crate) mod nats_token_policies;
1413
pub(crate) mod pending_prompt_waiters;
1514
pub mod session_id;
1615
pub mod subject_token_violation;

rsworkspace/crates/acp-nats/src/nats_token_policies.rs

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

rsworkspace/crates/acp-nats/src/session_id.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! ASCII only (recommended), rejecting `.` `*` `>` and whitespace (forbidden). Validity is
66
//! guaranteed at construction.
77
8-
use crate::nats_token_policies::SingleTokenPolicy;
98
use crate::subject_token_violation::SubjectTokenViolation;
109
use trogon_nats::NatsToken;
1110

@@ -34,7 +33,7 @@ impl std::error::Error for SessionIdError {}
3433
/// Follows [NATS subject naming](https://docs.nats.io/nats-concepts/subjects#characters-allowed-and-recommended-for-subject-names):
3534
/// ASCII only; rejects `.`, `*`, `>`, and whitespace. Max 128 characters.
3635
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
37-
pub struct AcpSessionId(NatsToken<SingleTokenPolicy>);
36+
pub struct AcpSessionId(NatsToken);
3837

3938
impl AcpSessionId {
4039
pub fn new(s: impl AsRef<str>) -> Result<Self, SessionIdError> {

rsworkspace/crates/trogon-nats/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod jetstream;
4444
pub mod messaging;
4545
pub mod nats_token;
4646
pub mod subject_token_violation;
47-
pub mod token;
47+
pub(crate) mod token;
4848

4949
#[cfg(feature = "test-support")]
5050
pub mod mocks;
@@ -59,7 +59,7 @@ pub use messaging::{
5959
RetryPolicy, build_request_headers, headers_with_trace_context, inject_trace_context, publish,
6060
request, request_with_timeout,
6161
};
62-
pub use nats_token::{NatsToken, NatsTokenPolicy};
62+
pub use nats_token::{DottedNatsToken, NatsToken};
6363
pub use subject_token_violation::SubjectTokenViolation;
6464

6565
#[cfg(feature = "test-support")]

0 commit comments

Comments
 (0)