gauth/user/data

Types

An error relating the the procurment of user data

pub type UserDataError(identifier) {
  NoSuchData(id: identifier)
  Generic(id: identifier, message: String)
}

Constructors

  • NoSuchData(id: identifier)

    The user has no relevent data

  • Generic(id: identifier, message: String)

    A generic error such as the data source being unreachable

A source to get a user by their ID

pub type UserDataService(identifier) {
  UserDataService(
    get_user: fn(identifier) -> Option(User(identifier)),
  )
}

Constructors

  • UserDataService(
      get_user: fn(identifier) -> Option(User(identifier)),
    )

A source to collect data for a user

pub type UserDataSource(identifier, data_store) {
  UserDataSource(
    get_data: fn(identifier) ->
      Result(data_store, UserDataError(identifier)),
  )
}

Constructors

  • UserDataSource(
      get_data: fn(identifier) ->
        Result(data_store, UserDataError(identifier)),
    )

Functions

pub fn get_data(
  user: User(a),
  data_source: UserDataSource(a, b),
) -> Result(b, UserDataError(a))

A stub method that just unwraps the user’s ID and then forwards it to the data store

Search Document