Skip to content

Commit

Permalink
♻️ Rename 'SessionId::as_string' to 'SessionId::to_repr'
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlm committed Jan 24, 2024
1 parent dd88e8b commit b8a1d28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions quickfix/src/session_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl SessionId {
}

/// Convert session ID to a nicely printable string.
pub fn as_string(&self) -> String {
pub fn to_repr(&self) -> String {
unsafe { FixSessionID_toString(self.0) }
.map(read_checked_cstr)
.unwrap_or_default()
Expand All @@ -83,7 +83,7 @@ impl Clone for SessionId {

impl fmt::Debug for SessionId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("SessionId").field(&self.as_string()).finish()
f.debug_tuple("SessionId").field(&self.to_repr()).finish()
}
}

Expand All @@ -103,6 +103,6 @@ mod tests {

let session2 = session1.clone();
assert_ne!(session1.0, session2.0);
assert_eq!(session1.as_string(), session2.as_string());
assert_eq!(session1.to_repr(), session2.to_repr());
}
}
8 changes: 4 additions & 4 deletions quickfix/tests/test_session_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn test_new() {
assert_eq!(session.get_sender_comp_id().as_deref(), Some("FOO"));
assert_eq!(session.get_target_comp_id().as_deref(), Some("BAR"));
assert_eq!(session.get_session_qualifier().as_deref(), Some(""));
assert_eq!(session.as_string(), "FIX.4.1:FOO->BAR");
assert_eq!(session.to_repr(), "FIX.4.1:FOO->BAR");
}

#[test]
Expand Down Expand Up @@ -37,12 +37,12 @@ fn test_fixt() {
#[test]
fn test_clone() {
let session1 = SessionId::try_new("FIX.4.1", "FOO", "BAR", "").unwrap();
assert_eq!(session1.as_string(), "FIX.4.1:FOO->BAR");
assert_eq!(session1.to_repr(), "FIX.4.1:FOO->BAR");

let session2 = session1.clone();
assert_eq!(session2.as_string(), "FIX.4.1:FOO->BAR");
assert_eq!(session2.to_repr(), "FIX.4.1:FOO->BAR");

// Test do not crash after drop
drop(session1);
assert_eq!(session2.as_string(), "FIX.4.1:FOO->BAR");
assert_eq!(session2.to_repr(), "FIX.4.1:FOO->BAR");
}
2 changes: 1 addition & 1 deletion quickfix/tests/utils/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ pub struct MsgCounter {
}

fn assert_session_id_equals(a: &SessionId, b: &SessionId) {
assert_eq!(a.as_string(), b.as_string());
assert_eq!(a.to_repr(), b.to_repr());
}

0 comments on commit b8a1d28

Please sign in to comment.