ig_client/session/
interface.rs

1use crate::error::AuthError;
2
3/// Session information for IG Markets API authentication
4#[derive(Debug, Clone)]
5pub struct IgSession {
6    /// Client Session Token (CST) used for authentication
7    pub cst: String,
8    /// Security token used for authentication
9    pub token: String,
10    /// Account ID associated with the session
11    pub account_id: String,
12}
13
14/// Trait for authenticating with the IG Markets API
15#[async_trait::async_trait]
16pub trait IgAuthenticator: Send + Sync {
17    /// Logs in to the IG Markets API and returns a new session
18    async fn login(&self) -> Result<IgSession, AuthError>;
19    /// Refreshes an existing session with the IG Markets API
20    async fn refresh(&self, session: &IgSession) -> Result<IgSession, AuthError>;
21}