Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement status codes by hand #321

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/ci_verify_clean_status_codes.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,3 @@ jobs:
verify-code-formatting:
uses: ./.github/workflows/ci_format_code.yml

verify-clean-status-codes:
uses: ./.github/workflows/ci_verify_clean_status_codes.yml
8 changes: 1 addition & 7 deletions lib/src/client/transport/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,7 @@ impl TransportState {
StatusCode::BadUnexpectedError
}
Message::Chunk(chunk) => self.process_chunk(chunk).err().unwrap_or(StatusCode::Good),
Message::Error(error) => {
if let Some(status_code) = StatusCode::from_u32(error.error) {
status_code
} else {
StatusCode::BadUnexpectedError
}
}
Message::Error(error) => StatusCode::from(error.error),
m => {
error!("Expected a recognized message, got {:?}", m);
StatusCode::BadUnexpectedError
Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/comms/tcp_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl ErrorMessage {
let mut error = ErrorMessage {
message_header: MessageHeader::new(MessageType::Error),
error: status_code.bits(),
reason: UAString::from(status_code.description()),
reason: UAString::from(status_code.sub_code().description()),
};
error.message_header.message_size = error.byte_len() as u32;
error
Expand Down
4 changes: 2 additions & 2 deletions lib/src/server/services/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub fn log_certificate_error(
let node_id = next_node_id(address_space);
let now = DateTime::now();

match status_code.status() {
StatusCode::BadCertificateTimeInvalid => {
match status_code.sub_code() {
SubStatusCode::BadCertificateTimeInvalid => {
let event = AuditCertificateExpiredEventType::new(node_id, now)
.client_audit_entry_id(request_header.audit_entry_id.clone());
let _ = server_state.raise_and_log(event);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/server/services/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl ViewService {
Err(err) => {
trace!(
"Browse path result for find nodes returned in error {}",
err.name()
err.sub_code().name()
);
BrowsePathResult {
status_code: err,
Expand Down
3 changes: 1 addition & 2 deletions lib/src/server/subscriptions/monitored_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ impl MonitoredItem {
if overflow {
if let Notification::MonitoredItemNotification(ref mut notification) = notification {
// Set the overflow bit on the data value's status
notification.value.status =
Some(notification.value.status() | StatusCode::OVERFLOW);
notification.value.status = Some(notification.value.status().set_overflow(true));
}
self.queue_overflow = true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::io::{Read, Write};

use crate::types::{
encoding::*, localized_text::LocalizedText, node_id::NodeId, status_codes::StatusCode,
encoding::*, localized_text::LocalizedText, node_id::NodeId, status_code::StatusCode,
string::UAString,
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/byte_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::types::{
process_decode_io_result, process_encode_io_result, write_i32, BinaryEncoder,
DecodingOptions, EncodingResult,
},
status_codes::StatusCode,
status_code::StatusCode,
Guid,
};

Expand Down
6 changes: 3 additions & 3 deletions lib/src/types/data_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::io::{Read, Write};
use crate::types::{
byte_string::ByteString, date_time::*, encoding::*, guid::Guid, localized_text::LocalizedText,
node_id::NodeId, qualified_name::QualifiedName, service_types::TimestampsToReturn,
status_codes::StatusCode, string::UAString, variant::Variant,
status_code::StatusCode, string::UAString, variant::Variant,
};

bitflags! {
Expand Down Expand Up @@ -126,7 +126,7 @@ impl BinaryEncoder<DataValue> for DataValue {
};
// Status
let status = if encoding_mask.contains(DataValueFlags::HAS_STATUS) {
let status = StatusCode::from_bits_truncate(u32::decode(stream, decoding_options)?);
let status = StatusCode::from(u32::decode(stream, decoding_options)?);
Some(status)
} else {
None
Expand Down Expand Up @@ -472,7 +472,7 @@ impl DataValue {
/// Test if the value held by this data value is known to be good
/// Anything other than Good is assumed to be invalid.
pub fn is_valid(&self) -> bool {
self.status().status().is_good()
self.status().is_good()
}

fn encoding_mask(&self) -> DataValueFlags {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/diagnostic_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::io::{Read, Write};

use crate::types::{encoding::*, status_codes::StatusCode, string::UAString};
use crate::types::{encoding::*, status_code::StatusCode, string::UAString};

bitflags! {
#[derive(Copy, Clone, Debug, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use chrono::Duration;

use crate::types::{constants, status_codes::StatusCode};
use crate::types::{constants, status_code::StatusCode};

pub type EncodingResult<T> = std::result::Result<T, StatusCode>;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/expanded_node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::types::{
encoding::*,
guid::Guid,
node_id::{Identifier, NodeId},
status_codes::StatusCode,
status_code::StatusCode,
string::*,
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/extension_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{

use super::{
byte_string::ByteString, encoding::*, node_id::NodeId, node_ids::ObjectId,
status_codes::StatusCode, string::XmlElement,
status_code::StatusCode, string::XmlElement,
};

#[derive(Debug)]
Expand Down
4 changes: 1 addition & 3 deletions lib/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ bitflags! {
}
}

// These 3 modules are autogenerated
#[rustfmt::skip]
mod status_codes;
// These 2 modules are autogenerated
#[rustfmt::skip]
pub mod node_ids;
#[rustfmt::skip]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::types::{
encoding::*,
guid::Guid,
node_ids::{ObjectId, ReferenceTypeId},
status_codes::StatusCode,
status_code::StatusCode,
string::*,
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/response_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{

use crate::types::{
data_types::*, date_time::DateTime, diagnostic_info::DiagnosticInfo, encoding::*,
extension_object::ExtensionObject, request_header::RequestHeader, status_codes::StatusCode,
extension_object::ExtensionObject, request_header::RequestHeader, status_code::StatusCode,
string::UAString,
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/activate_session_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::types::{
basic_types::*, byte_string::ByteString, diagnostic_info::DiagnosticInfo, encoding::*,
node_ids::ObjectId, response_header::ResponseHeader, service_types::impls::MessageInfo,
status_codes::StatusCode,
status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/add_nodes_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, encoding::*, node_id::NodeId, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode,
service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/add_references_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/browse_path_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, encoding::*, node_ids::ObjectId, service_types::impls::MessageInfo,
service_types::BrowsePathTarget, status_codes::StatusCode,
service_types::BrowsePathTarget, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/browse_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::types::{
basic_types::*, byte_string::ByteString, encoding::*, node_ids::ObjectId,
service_types::impls::MessageInfo, service_types::ReferenceDescription,
status_codes::StatusCode,
status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/call_method_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode, variant::Variant,
service_types::impls::MessageInfo, status_code::StatusCode, variant::Variant,
};
use std::io::{Read, Write};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode,
service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/delete_nodes_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/delete_references_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// DO NOT EDIT THIS FILE
#![allow(unused_attributes)]
#![allow(non_upper_case_globals)]
use crate::types::{encoding::*, status_codes::StatusCode};
use crate::types::{encoding::*, status_code::StatusCode};
use bitflags;
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/event_filter_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*,
service_types::ContentFilterResult, status_codes::StatusCode,
service_types::ContentFilterResult, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/history_read_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, byte_string::ByteString, encoding::*, extension_object::ExtensionObject,
node_ids::ObjectId, service_types::impls::MessageInfo, status_codes::StatusCode,
node_ids::ObjectId, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/history_update_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode,
service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::types::{
MonitoringParameters, ReadValueId, ServiceCounterDataType, ServiceFault, SignatureData,
UserNameIdentityToken, UserTokenPolicy, UserTokenType,
},
status_codes::StatusCode,
status_code::StatusCode,
string::UAString,
variant::Variant,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, encoding::*, extension_object::ExtensionObject, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode,
service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, encoding::*, extension_object::ExtensionObject, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode,
service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/parsing_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
service_types::impls::MessageInfo, status_codes::StatusCode,
service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/publish_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo,
service_types::NotificationMessage, status_codes::StatusCode,
service_types::NotificationMessage, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/service_types/register_server_2_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[allow(unused_imports)]
use crate::types::{
basic_types::*, diagnostic_info::DiagnosticInfo, encoding::*, node_ids::ObjectId,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_codes::StatusCode,
response_header::ResponseHeader, service_types::impls::MessageInfo, status_code::StatusCode,
};
use std::io::{Read, Write};

Expand Down
Loading
Loading