pub fn create_token(
        &self,
        permissions: usize,
        user: Option<String>,
        description: Option<String>,
        allowed_indexes: Option<Vec<String>>,
    ) -> Arc<TokenData> {
        let created = Utc::now();
        let token: String = rand::thread_rng()
            .sample_iter(&Alphanumeric)
            .take(64)
            .map(char::from)
            .collect();

        let data = Arc::new(TokenData {
            token,
            allowed_indexes,
            permissions,
            created,
            user,
            description,
        });

        let mut new;
        {
            let existing = self.keys.load();
            new = existing.as_ref().clone();
            new.insert(data.token.clone(), data.clone());
        }
        self.keys.store(Arc::new(new));

        data
    }
/// Creates a new access token.
///
/// This generates a 64 character long random token which has the given
/// set of metadata associated with it.
Creates a new access token.
This generates a 64 character long random token which has the given
set of metadata associated with it.
Creates a new access token . This generates a 64 character long random token which has the given set of metadata associated with it .
pub fn create_token(
        &self,
        permissions: usize,
        user: Option<String>,
        description: Option<String>,
        allowed_indexes: Option<Vec<String>>,
    ) -> Arc<TokenData> {
        let created = Utc::now();
        let token: String = rand::thread_rng()
            .sample_iter(&Alphanumeric)
            .take(64)
            .map(char::from)
            .collect();
        let data = Arc::new(TokenData {
            token,
            allowed_indexes,
            permissions,
            created,
            user,
            description,
        });
        let mut new;
        {
            let existing = self.keys.load();
            new = existing.as_ref().clone();
            new.insert(data.token.clone(), data.clone());
        }
        self.keys.store(Arc::new(new));
        data
    }
pub fn create_token ( & self , permissions : usize , user : Option < String > , description : Option < String > , allowed_indexes : Option < Vec < String > > , ) -> Arc < TokenData > { let created = Utc :: now ( ) ; let token : String = rand :: thread_rng ( ) . sample_iter ( & Alphanumeric ) . take ( 64 ) . map ( char :: from ) . collect ( ) ; let data = Arc :: new ( TokenData { token , allowed_indexes , permissions , created , user , description , } ) ; let mut new ; { let existing = self . keys . load ( ) ; new = existing . as_ref ( ) . clone ( ) ; new . insert ( data . token . clone ( ) , data . clone ( ) ) ; } self . keys . store ( Arc :: new ( new ) ) ; data }
Creates a new access token.
Creates a new access token .
&self
permissions
usize
user
Option<String>
description
Option<String>
allowed_indexes
Option<Vec<String>>
&self
permissions
usize
user
Option<String>
description
Option<String>
allowed_indexes
Option<Vec<String>>