Skip to content

Commit a981ae4

Browse files
committed
Update Rust docs
1 parent 9751400 commit a981ae4

File tree

119 files changed

+171
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+171
-37
lines changed

nautilus_core/accounting/src/account/base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct BaseAccount {
4444
}
4545

4646
impl BaseAccount {
47+
/// Creates a new [`BaseAccount`] instance.
4748
pub fn new(event: AccountState, calculate_account_state: bool) -> anyhow::Result<Self> {
4849
let mut balances_starting: HashMap<Currency, Money> = HashMap::new();
4950
let mut balances: HashMap<Currency, AccountBalance> = HashMap::new();

nautilus_core/accounting/src/account/cash.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct CashAccount {
4343
}
4444

4545
impl CashAccount {
46+
/// Creates a new [`CashAccount`] instance.
4647
pub fn new(event: AccountState, calculate_account_state: bool) -> anyhow::Result<Self> {
4748
Ok(Self {
4849
base: BaseAccount::new(event, calculate_account_state)?,

nautilus_core/accounting/src/account/margin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub struct MarginAccount {
5454
}
5555

5656
impl MarginAccount {
57+
/// Creates a new [`MarginAccount`] instance.
5758
pub fn new(event: AccountState, calculate_account_state: bool) -> anyhow::Result<Self> {
5859
Ok(Self {
5960
base: BaseAccount::new(event, calculate_account_state)?,

nautilus_core/adapters/src/databento/live.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub struct DatabentoFeedHandler {
8383
}
8484

8585
impl DatabentoFeedHandler {
86-
/// Initialize a new instance of the [`DatabentoFeedHandler`].
86+
/// Creates a new [`DatabentoFeedHandler`] instance.
8787
#[must_use]
8888
pub fn new(
8989
key: String,

nautilus_core/adapters/src/databento/loader.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub struct DatabentoDataLoader {
6868
}
6969

7070
impl DatabentoDataLoader {
71+
/// Creates a new [`DatabentoDataLoader`] instance.
7172
pub fn new(path: Option<PathBuf>) -> anyhow::Result<Self> {
7273
let mut loader = Self {
7374
publishers_map: IndexMap::new(),

nautilus_core/adapters/src/databento/types.rs

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub struct DatabentoImbalance {
8585
}
8686

8787
impl DatabentoImbalance {
88+
/// Creates a new [`DatabentoImbalance`] instance.
8889
#[allow(clippy::too_many_arguments)]
8990
pub fn new(
9091
instrument_id: InstrumentId,
@@ -154,6 +155,7 @@ pub struct DatabentoStatistics {
154155
}
155156

156157
impl DatabentoStatistics {
158+
/// Creates a new [`DatabentoStatistics`] instance.
157159
#[allow(clippy::too_many_arguments)]
158160
pub fn new(
159161
instrument_id: InstrumentId,

nautilus_core/backtest/src/engine.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct TimeEventAccumulator {
2929
}
3030

3131
impl TimeEventAccumulator {
32-
/// Creates a new `TimeEventAccumulator` instance.
32+
/// Creates a new [`TimeEventAccumulator`] instance.
3333
#[must_use]
3434
pub fn new() -> Self {
3535
Self {
@@ -55,6 +55,7 @@ impl TimeEventAccumulator {
5555
}
5656

5757
impl Default for TimeEventAccumulator {
58+
/// Creates a new default [`TimeEventAccumulator`] instance.
5859
fn default() -> Self {
5960
Self::new()
6061
}

nautilus_core/backtest/src/matching_engine.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ pub struct OrderMatchingEngine {
9191
execution_count: usize,
9292
}
9393

94-
// Note: we'll probably be changing the `FillModel` (don't add for now)
94+
// TODO: we'll probably be changing the `FillModel` (don't add for now)
9595
impl OrderMatchingEngine {
96+
/// Creates a new [`OrderMatchingEngine`] instance.
9697
#[allow(clippy::too_many_arguments)]
9798
pub fn new(
9899
instrument: Box<dyn Instrument>,

nautilus_core/common/src/cache/core.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct CacheConfig {
6464
}
6565

6666
impl CacheConfig {
67+
/// Creates a new [`CacheConfig`] instance.
6768
#[allow(clippy::too_many_arguments)]
6869
#[must_use]
6970
pub fn new(
@@ -90,7 +91,7 @@ impl CacheConfig {
9091
}
9192

9293
impl Default for CacheConfig {
93-
/// Creates a new default `CacheConfig` instance.
94+
/// Creates a new default [`CacheConfig`] instance.
9495
fn default() -> Self {
9596
Self::new(
9697
SerializationEncoding::MsgPack,
@@ -192,14 +193,14 @@ pub struct Cache {
192193
}
193194

194195
impl Default for Cache {
195-
/// Creates a new default `Cache` instance.
196+
/// Creates a new default [`Cache`] instance.
196197
fn default() -> Self {
197198
Self::new(CacheConfig::default(), None)
198199
}
199200
}
200201

201202
impl Cache {
202-
/// Creates a new `Cache` instance.
203+
/// Creates a new [`Cache`] instance.
203204
#[must_use]
204205
pub fn new(config: CacheConfig, database: Option<CacheDatabaseAdapter>) -> Self {
205206
let index = CacheIndex {

nautilus_core/common/src/cache/database.rs

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub struct DatabaseCommand {
5858
}
5959

6060
impl DatabaseCommand {
61+
/// Creates a new [`DatabaseCommand`] instance.
6162
#[must_use]
6263
pub fn new(op_type: DatabaseOperation, key: String, payload: Option<Vec<Vec<u8>>>) -> Self {
6364
Self {

nautilus_core/common/src/clock.rs

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub struct TestClock {
8282
}
8383

8484
impl TestClock {
85+
/// Creates a new [`TestClock`] instance.
8586
#[must_use]
8687
pub fn new() -> Self {
8788
Self {
@@ -152,6 +153,7 @@ fn create_time_event_handler(event: TimeEvent, handler: &EventHandler) -> TimeEv
152153
}
153154

154155
impl Default for TestClock {
156+
/// Creates a new default [`TestClock`] instance.
155157
fn default() -> Self {
156158
Self::new()
157159
}
@@ -274,6 +276,7 @@ pub struct LiveClock {
274276
}
275277

276278
impl LiveClock {
279+
/// Creates a new [`LiveClock`] instance.
277280
#[must_use]
278281
pub fn new() -> Self {
279282
Self {
@@ -290,6 +293,7 @@ impl LiveClock {
290293
}
291294

292295
impl Default for LiveClock {
296+
/// Creates a new default [`LiveClock`] instance.
293297
fn default() -> Self {
294298
Self::new()
295299
}

nautilus_core/common/src/factories.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct OrderFactory {
4444
}
4545

4646
impl OrderFactory {
47+
/// Creates a new [`OrderFactory`] instance.
4748
pub fn new(
4849
trader_id: TraderId,
4950
strategy_id: StrategyId,

nautilus_core/common/src/generators/client_order_id.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct ClientOrderIdGenerator {
2929
}
3030

3131
impl ClientOrderIdGenerator {
32+
/// Creates a new [`ClientOrderIdGenerator`] instance.
3233
#[must_use]
3334
pub fn new(
3435
trader_id: TraderId,

nautilus_core/common/src/generators/order_list_id.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct OrderListIdGenerator {
2929
}
3030

3131
impl OrderListIdGenerator {
32+
/// Creates a new [`OrderListIdGenerator`] instance.
3233
#[must_use]
3334
pub fn new(
3435
trader_id: TraderId,

nautilus_core/common/src/generators/position_id.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub struct PositionIdGenerator {
3030
}
3131

3232
impl PositionIdGenerator {
33+
/// Creates a new [`PositionIdGenerator`] instance.
3334
#[must_use]
3435
pub fn new(trader_id: TraderId, clock: &'static AtomicTime) -> Self {
3536
Self {

nautilus_core/common/src/logging/logger.rs

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct LoggerConfig {
6464
}
6565

6666
impl Default for LoggerConfig {
67+
/// Creates a new default [`LoggerConfig`] instance.
6768
fn default() -> Self {
6869
Self {
6970
stdout_level: LevelFilter::Info,
@@ -76,6 +77,7 @@ impl Default for LoggerConfig {
7677
}
7778

7879
impl LoggerConfig {
80+
/// Creates a new [`LoggerConfig`] instance.
7981
#[must_use]
8082
pub fn new(
8183
stdout_level: LevelFilter,
@@ -194,6 +196,7 @@ pub struct LogLineWrapper {
194196
}
195197

196198
impl LogLineWrapper {
199+
/// Creates a new [`LogLineWrapper`] instance.
197200
#[must_use]
198201
pub fn new(line: LogLine, trader_id: Ustr, timestamp: UnixNanos) -> Self {
199202
Self {
@@ -479,13 +482,15 @@ pub struct LogGuard {
479482
}
480483

481484
impl LogGuard {
485+
/// Creates a new [`LogGuard`] instance.
482486
#[must_use]
483487
pub fn new(handle: Option<JoinHandle<()>>) -> Self {
484488
Self { handle }
485489
}
486490
}
487491

488492
impl Default for LogGuard {
493+
/// Creates a new default [`LogGuard`] instance.
489494
fn default() -> Self {
490495
Self::new(None)
491496
}

nautilus_core/common/src/logging/writer.rs

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub struct StdoutWriter {
4242
}
4343

4444
impl StdoutWriter {
45+
/// Creates a new [`StdoutWriter`] instance.
4546
#[must_use]
4647
pub fn new(level: LevelFilter, is_colored: bool) -> Self {
4748
Self {
@@ -80,6 +81,7 @@ pub struct StderrWriter {
8081
}
8182

8283
impl StderrWriter {
84+
/// Creates a new [`StderrWriter`] instance.
8385
#[must_use]
8486
pub fn new(is_colored: bool) -> Self {
8587
Self {
@@ -121,6 +123,7 @@ pub struct FileWriterConfig {
121123
}
122124

123125
impl FileWriterConfig {
126+
/// Creates a new [`FileWriterConfig`] instance.
124127
#[must_use]
125128
pub fn new(
126129
directory: Option<String>,
@@ -147,6 +150,7 @@ pub struct FileWriter {
147150
}
148151

149152
impl FileWriter {
153+
/// Creates a new [`FileWriter`] instance.
150154
pub fn new(
151155
trader_id: String,
152156
instance_id: String,

nautilus_core/common/src/msgbus/core.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct Subscription {
4343
}
4444

4545
impl Subscription {
46+
/// Creates a new [`Subscription`] instance.
4647
#[must_use]
4748
pub fn new(
4849
topic: Ustr,
@@ -165,7 +166,7 @@ pub struct MessageBus {
165166
}
166167

167168
impl MessageBus {
168-
/// Creates a new `MessageBus` instance.
169+
/// Creates a new [`MessageBus`] instance.
169170
pub fn new(
170171
trader_id: TraderId,
171172
instance_id: UUID4,

nautilus_core/common/src/timer.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ pub struct TimeEvent {
5959
pub ts_init: UnixNanos,
6060
}
6161

62-
/// Assumes `name` is a valid string.
6362
impl TimeEvent {
63+
/// Creates a new [`TimeEvent`] instance.
64+
///
65+
/// Assumes `name` is a valid string.
6466
#[must_use]
6567
pub fn new(name: Ustr, event_id: UUID4, ts_event: UnixNanos, ts_init: UnixNanos) -> Self {
6668
Self {
@@ -92,7 +94,7 @@ impl PartialEq for TimeEvent {
9294
#[derive(Clone, Debug)]
9395
/// Represents a time event and its associated handler.
9496
pub struct TimeEventHandler {
95-
/// The event.
97+
/// The time event.
9698
pub event: TimeEvent,
9799
/// The callable raw pointer.
98100
pub callback_ptr: *mut c_char,
@@ -130,7 +132,7 @@ pub struct TestTimer {
130132
}
131133

132134
impl TestTimer {
133-
/// Creates a new `TestTimer` instance.
135+
/// Creates a new [`TestTimer`] instance.
134136
pub fn new(
135137
name: &str,
136138
interval_ns: u64,
@@ -233,7 +235,7 @@ pub struct LiveTimer {
233235
}
234236

235237
impl LiveTimer {
236-
/// Creates a new `LiveTimer` instance.
238+
/// Creates a new [`LiveTimer`] instance.
237239
pub fn new(
238240
name: &str,
239241
interval_ns: u64,

nautilus_core/core/src/time.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ impl Deref for AtomicTime {
8585
}
8686

8787
impl Default for AtomicTime {
88+
/// Creates a new default [`AtomicTime`] instance.
8889
fn default() -> Self {
8990
Self::new(true, UnixNanos::default())
9091
}
9192
}
9293

9394
impl AtomicTime {
94-
/// New atomic clock set with the given UNIX time (nanoseconds).
95+
/// Creates a new [`AtomicTime`] instance.
96+
///
97+
/// The `realtime` flag will determine whether the atomic time is based off system time.
98+
/// The time will be set to the given UNIX `time` (nanoseconds).
9599
#[must_use]
96100
pub fn new(realtime: bool, time: UnixNanos) -> Self {
97101
Self {

nautilus_core/core/src/uuid.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct UUID4 {
4343
}
4444

4545
impl UUID4 {
46-
/// Creates a new `UUID4` instance.
46+
/// Creates a new [`UUID4`] instance.
4747
#[must_use]
4848
pub fn new() -> Self {
4949
let uuid = Uuid::new_v4();
@@ -84,6 +84,7 @@ impl From<&str> for UUID4 {
8484
}
8585

8686
impl Default for UUID4 {
87+
/// Creates a new default [`UUID4`] instance.
8788
fn default() -> Self {
8889
Self::new()
8990
}

nautilus_core/execution/src/matching_core.rs

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct OrderMatchingCore {
5151
}
5252

5353
impl OrderMatchingCore {
54+
// Creates a new [`OrderMatchingCore`] instance.
5455
#[must_use]
5556
pub fn new(
5657
instrument_id: InstrumentId,

nautilus_core/execution/src/messages/cancel.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct CancelOrder {
3838
}
3939

4040
impl CancelOrder {
41+
/// Creates a new [`CancelOrder`] instance.
4142
#[allow(clippy::too_many_arguments)]
4243
pub fn new(
4344
trader_id: TraderId,

nautilus_core/execution/src/messages/cancel_all.rs

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub struct CancelAllOrders {
4040
}
4141

4242
impl CancelAllOrders {
43+
/// Creates a new [`CancelAllOrders`] instance.
4344
#[allow(clippy::too_many_arguments)]
4445
pub fn new(
4546
trader_id: TraderId,

nautilus_core/execution/src/messages/cancel_batch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct BatchCancelOrders {
3838
}
3939

4040
impl BatchCancelOrders {
41+
/// Creates a new [`BatchCancelOrders`] instance.
4142
#[allow(clippy::too_many_arguments)]
4243
pub fn new(
4344
trader_id: TraderId,

nautilus_core/execution/src/messages/modify.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct ModifyOrder {
4444
}
4545

4646
impl ModifyOrder {
47+
/// Creates a new [`ModifyOrder`] instance.
4748
#[allow(clippy::too_many_arguments)]
4849
pub fn new(
4950
trader_id: TraderId,

0 commit comments

Comments
 (0)