Skip to main content

Notice

Struct Notice 

Source
pub struct Notice {
    pub code: i32,
    pub message: String,
    pub error_time: Option<OffsetDateTime>,
    pub advanced_order_reject_json: String,
}
Expand description

An error message from the TWS API.

Fields§

§code: i32

Error code reported by TWS.

§message: String

Human-readable error message text.

§error_time: Option<OffsetDateTime>

Timestamp when the error occurred. Only present for server versions >= ERROR_TIME (194).

§advanced_order_reject_json: String

Advanced order-reject JSON payload, present on hard order-rejection notices for server versions >= ADVANCED_ORDER_REJECT. Empty otherwise.

Implementations§

Source§

impl Notice

Source

pub fn is_cancellation(&self) -> bool

Returns true if this notice indicates an order was cancelled (code 202).

Code 202 is sent by TWS to confirm an order cancellation. This is an informational message, not an error.

Source

pub fn is_warning(&self) -> bool

Returns true if this is a warning message (codes 2100-2169).

Source

pub fn is_system_message(&self) -> bool

Returns true if this is a system/connectivity message (codes 1100-1102, 1300).

System messages indicate connectivity status changes:

  • 1100: Connectivity between IB and TWS lost
  • 1101: Connectivity restored, market data lost (resubscribe needed)
  • 1102: Connectivity restored, market data maintained
  • 1300: Socket port reset during active connection
Source

pub fn is_data_advisory(&self) -> bool

Returns true if this is a data advisory (DATA_ADVISORY_CODES).

Data advisories (codes 10089, 10167) announce that a request proceeded with a fallback — delayed market data instead of real-time — rather than failing. The requested data still follows, so the subscription stays open and the notice is informational, not an error.

Source

pub fn is_informational(&self) -> bool

Returns true if this is an informational notice (not an error).

Informational notices include cancellation confirmations, warnings, system/connectivity messages, and data advisories.

Source

pub fn is_error(&self) -> bool

Returns true if this is an error requiring attention.

Returns false for informational messages like cancellation confirmations, warnings, and system messages.

Source

pub fn is_order_rejection(&self) -> bool

Returns true if this notice falls in the order-rejection range (200-399).

Code 202 (cancellation confirmation) is numerically inside this range; this predicate returns true for it. For a disjoint partition that routes 202 to NoticeCategory::Cancellation instead, use Notice::category.

§Examples
use ibapi::Notice;
if notice.is_order_rejection() {
    eprintln!("rejection: {}", notice);
}
Source

pub fn is_handshake_synthetic(&self) -> bool

Returns true if this notice was synthesized client-side during the connection handshake — i.e. carries either HANDSHAKE_UNKNOWN_FRAME_CODE (an IncomingMessages kind with no typed StartupMessage variant) or HANDSHAKE_DECODE_FAILURE_CODE (a typed decoder failed on a known kind).

Subscribers to Client::notice_stream can use this to log + investigate without conflating with TWS-emitted notices.

§Examples
use ibapi::Notice;
if notice.is_handshake_synthetic() {
    eprintln!("handshake observability: code={} {}", notice.code, notice);
}
Source

pub fn category(&self) -> NoticeCategory

Classify this notice into a disjoint NoticeCategory.

See NoticeCategory for the precedence chain.

§Examples
use ibapi::{Notice, NoticeCategory};
let level = match notice.category() {
    NoticeCategory::Cancellation
    | NoticeCategory::Warning
    | NoticeCategory::SystemMessage => "info",
    NoticeCategory::OrderRejection | NoticeCategory::Error => "error",
    _ => "unknown",
};
Source

pub fn connectivity_status(&self) -> Option<ConnectivityStatus>

Classify the data-farm connectivity sub-state of this notice.

Returns Some(..) for the data-farm status codes inside WARNING_CODE_RANGE; None for every other notice. Additive to Notice::category, which still classifies all of 2100..=2169 as NoticeCategory::Warning. Thin wrapper over ConnectivityStatus::from_code.

§Examples
use ibapi::{Notice, ConnectivityStatus};
if notice.connectivity_status() == Some(ConnectivityStatus::Broken) {
    eprintln!("data farm down: {notice}");
}

Trait Implementations§

Source§

impl Clone for Notice

Source§

fn clone(&self) -> Notice

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComposeSchema for Notice

Source§

impl Debug for Notice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Notice

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Notice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Notice

Source§

fn eq(&self, other: &Notice) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Notice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Notice

Source§

impl ToSchema for Notice

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference utoipa::openapi::schema::Schemas for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

Source§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.