From abc737e8ac2790aba0648a5a3c3dab2429b59186 Mon Sep 17 00:00:00 2001 From: David Steiner Date: Tue, 4 Nov 2025 10:20:57 +0100 Subject: [PATCH] Make smartstrings a default feature --- crates/hotfix-dictionary/Cargo.toml | 4 +++- crates/hotfix-dictionary/src/component.rs | 3 +-- crates/hotfix-dictionary/src/dictionary.rs | 2 +- crates/hotfix-dictionary/src/field.rs | 2 +- crates/hotfix-dictionary/src/layout.rs | 2 +- crates/hotfix-dictionary/src/lib.rs | 1 + crates/hotfix-dictionary/src/message_definition.rs | 2 +- crates/hotfix-dictionary/src/quickfix.rs | 3 +-- crates/hotfix-dictionary/src/string.rs | 4 ++++ 9 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 crates/hotfix-dictionary/src/string.rs diff --git a/crates/hotfix-dictionary/Cargo.toml b/crates/hotfix-dictionary/Cargo.toml index 19ae9ed..be7bbe6 100644 --- a/crates/hotfix-dictionary/Cargo.toml +++ b/crates/hotfix-dictionary/Cargo.toml @@ -12,6 +12,7 @@ keywords.workspace = true categories.workspace = true [features] +default = ["smartstring"] fix40 = [] fix41 = [] fix42 = [] @@ -21,6 +22,7 @@ fix50 = [] fix50sp1 = [] fix50sp2 = [] fixt11 = [] +smartstring = ["dep:smartstring"] [lints] workspace = true @@ -28,6 +30,6 @@ workspace = true [dependencies] fnv.workspace = true roxmltree.workspace = true -smartstring.workspace = true +smartstring = { workspace = true, optional = true } strum.workspace = true strum_macros.workspace = true diff --git a/crates/hotfix-dictionary/src/component.rs b/crates/hotfix-dictionary/src/component.rs index 36950aa..cfcc370 100644 --- a/crates/hotfix-dictionary/src/component.rs +++ b/crates/hotfix-dictionary/src/component.rs @@ -1,5 +1,4 @@ -use smartstring::alias::String as SmartString; - +use crate::string::SmartString; use crate::{Dictionary, Field, LayoutItem, LayoutItemData, LayoutItemKind}; /// A [`Component`] is an ordered collection of fields and/or other components. diff --git a/crates/hotfix-dictionary/src/dictionary.rs b/crates/hotfix-dictionary/src/dictionary.rs index d4fcd96..42b0008 100644 --- a/crates/hotfix-dictionary/src/dictionary.rs +++ b/crates/hotfix-dictionary/src/dictionary.rs @@ -2,8 +2,8 @@ use crate::{Component, ComponentData, Datatype, DatatypeData, Field, FieldData}; use crate::message_definition::{MessageData, MessageDefinition}; use crate::quickfix::{ParseDictionaryError, QuickFixReader}; +use crate::string::SmartString; use fnv::FnvHashMap; -use smartstring::alias::String as SmartString; /// Specifies business semantics for application-level entities within the FIX /// Protocol. diff --git a/crates/hotfix-dictionary/src/field.rs b/crates/hotfix-dictionary/src/field.rs index 453a5a6..3e36650 100644 --- a/crates/hotfix-dictionary/src/field.rs +++ b/crates/hotfix-dictionary/src/field.rs @@ -1,5 +1,5 @@ +use crate::string::SmartString; use crate::{Datatype, Dictionary, FixDatatype, TagU32}; -use smartstring::alias::String as SmartString; pub trait IsFieldDefinition { /// Returns the FIX tag associated with `self`. diff --git a/crates/hotfix-dictionary/src/layout.rs b/crates/hotfix-dictionary/src/layout.rs index c2ece29..13f2123 100644 --- a/crates/hotfix-dictionary/src/layout.rs +++ b/crates/hotfix-dictionary/src/layout.rs @@ -1,7 +1,7 @@ -use smartstring::alias::String as SmartString; use std::fmt; use crate::component::Component; +use crate::string::SmartString; use crate::{Dictionary, Field}; pub fn display_layout_item(indent: u32, item: LayoutItem, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/crates/hotfix-dictionary/src/lib.rs b/crates/hotfix-dictionary/src/lib.rs index 78eb78b..fb25d6d 100644 --- a/crates/hotfix-dictionary/src/lib.rs +++ b/crates/hotfix-dictionary/src/lib.rs @@ -8,6 +8,7 @@ mod field; mod layout; mod message_definition; mod quickfix; +mod string; use component::{Component, ComponentData}; use datatype::DatatypeData; diff --git a/crates/hotfix-dictionary/src/message_definition.rs b/crates/hotfix-dictionary/src/message_definition.rs index 154a29b..aca92e8 100644 --- a/crates/hotfix-dictionary/src/message_definition.rs +++ b/crates/hotfix-dictionary/src/message_definition.rs @@ -1,5 +1,5 @@ +use crate::string::SmartString; use crate::{Dictionary, LayoutItem, LayoutItems}; -use smartstring::alias::String as SmartString; #[derive(Clone, Debug)] pub struct MessageData { diff --git a/crates/hotfix-dictionary/src/quickfix.rs b/crates/hotfix-dictionary/src/quickfix.rs index 6d1fba9..9b587d1 100644 --- a/crates/hotfix-dictionary/src/quickfix.rs +++ b/crates/hotfix-dictionary/src/quickfix.rs @@ -1,8 +1,7 @@ -use smartstring::alias::String as SmartString; - use crate::builder::DictionaryBuilder; use crate::component::{ComponentData, FixmlComponentAttributes}; use crate::message_definition::MessageData; +use crate::string::SmartString; use crate::{ DatatypeData, Dictionary, FieldData, FieldEnumData, FixDatatype, LayoutItemData, LayoutItemKindData, LayoutItems, diff --git a/crates/hotfix-dictionary/src/string.rs b/crates/hotfix-dictionary/src/string.rs new file mode 100644 index 0000000..2c80524 --- /dev/null +++ b/crates/hotfix-dictionary/src/string.rs @@ -0,0 +1,4 @@ +#[cfg(feature = "smartstring")] +pub(crate) use smartstring::alias::String as SmartString; +#[cfg(not(feature = "smartstring"))] +pub(crate) use std::string::String as SmartString;