Skip to content

Commit

Permalink
refactor: Drop legacy constants module imports and methods (#342)
Browse files Browse the repository at this point in the history
* refactor: Drop imports from redundant constants module

* refactor: Cease using legacy numeric constants
  • Loading branch information
AiyionPrime authored Jul 21, 2024
1 parent 1f94774 commit ce9cd86
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 17 deletions.
5 changes: 1 addition & 4 deletions lib/src/core/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (C) 2017-2024 Adam Lock

use std::{
sync::atomic::{AtomicU32, Ordering},
u32,
};
use std::sync::atomic::{AtomicU32, Ordering};

/// A simple handle factory for incrementing sequences of numbers.
#[derive(Debug, Clone, Serialize)]
Expand Down
1 change: 0 additions & 1 deletion lib/src/server/address_space/address_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ impl AddressSpace {
/// The last registered namespace becomes the default namespace unless you explcitly call
/// `set_default_namespace()` after this.
pub fn register_namespace(&mut self, namespace: &str) -> Result<u16, ()> {
use std::u16;
let now = DateTime::now();
if namespace.is_empty() || self.namespaces.len() == u16::MAX as usize {
Err(())
Expand Down
2 changes: 0 additions & 2 deletions lib/src/server/address_space/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@ impl Variable {
data_encoding: &QualifiedName,
max_age: f64,
) -> DataValue {
use std::i32;

if let Some(ref value_getter) = self.value_getter {
let mut value_getter = value_getter.lock();
value_getter
Expand Down
4 changes: 2 additions & 2 deletions lib/src/server/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use super::constants;

pub const ANONYMOUS_USER_TOKEN_ID: &str = "ANONYMOUS";

const RECEIVE_BUFFER_SIZE: usize = std::u16::MAX as usize;
const SEND_BUFFER_SIZE: usize = std::u16::MAX as usize;
const RECEIVE_BUFFER_SIZE: usize = u16::MAX as usize;
const SEND_BUFFER_SIZE: usize = u16::MAX as usize;

#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct TcpConfig {
Expand Down
1 change: 0 additions & 1 deletion lib/src/server/services/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ impl ViewService {
}
Ok(result) => {
let targets = if !result.is_empty() {
use std::u32;
let targets = result
.iter()
.map(|node_id| BrowsePathTarget {
Expand Down
1 change: 0 additions & 1 deletion lib/src/server/subscriptions/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ impl Subscription {
}

fn enqueue_notification(&mut self, notification: NotificationMessage) {
use std::u32;
// For sanity, check the sequence number is the expected sequence number.
let expected_sequence_number = if self.last_sequence_number == u32::MAX {
1
Expand Down
4 changes: 2 additions & 2 deletions lib/src/types/date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl From<DateTimeUtc> for DateTime {

impl From<i64> for DateTime {
fn from(value: i64) -> Self {
if value == i64::max_value() {
if value == i64::MAX {
// Max signifies end times
Self::endtimes()
} else {
Expand Down Expand Up @@ -315,7 +315,7 @@ impl DateTime {
return 0;
}
if nanos > Self::endtimes_ticks() {
return i64::max_value();
return i64::MAX;
}
nanos
}
Expand Down
1 change: 0 additions & 1 deletion lib/src/types/expanded_node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
self, fmt,
io::{Read, Write},
str::FromStr,
u16, u32,
};

use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
Expand Down
1 change: 0 additions & 1 deletion lib/src/types/node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
io::{Read, Write},
str::FromStr,
sync::atomic::{AtomicUsize, Ordering},
u16, u32,
};

use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
Expand Down
1 change: 0 additions & 1 deletion lib/src/types/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::{
fmt,
io::{Read, Write},
str::FromStr,
{i16, i32, i64, i8, u16, u32, u64, u8},
};

use crate::types::{
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/variant_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! To distinguish between binary and JSON, the built-in types implement Serde's `Serialize`/`Deserialize`
//! traits for JSON serialization.
use std::{fmt, i32};
use std::fmt;

use serde::{
de, de::DeserializeOwned, de::Error, Deserialize, Deserializer, Serialize, Serializer,
Expand Down

0 comments on commit ce9cd86

Please sign in to comment.