eio_okta_sync/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#![allow(clippy::result_large_err)]

pub mod command;
pub mod crossplane;
pub mod github;
pub mod kubernetes;
pub mod okta;

#[derive(Debug, thiserror::Error, miette::Diagnostic)]
#[error(transparent)]
#[allow(clippy::large_enum_variant)]
#[remain::sorted]
#[non_exhaustive]
pub enum Error {
  Client(#[from] eio_okta_client::Error),
  Inquire(#[from] inquire::error::InquireError),
  IO(#[from] std::io::Error),
  IriStringTemplate(#[from] iri_string::template::Error),
  IriStringValidate(#[from] iri_string::validate::Error),
  Json(#[from] serde_json::Error),
  #[error("missing github access token")]
  MissingGithubAccessToken,
  Octocrab(#[from] octocrab::Error),
  Yaml(#[from] serde_yml::Error),
}

pub trait MapInto<T, E> {
  fn map_into(self) -> Result<T, E>;
}

impl<OkFrom, ErrFrom, OkInto, ErrInto> MapInto<OkInto, ErrInto> for Result<OkFrom, ErrFrom>
where
  OkFrom: Into<OkInto>,
  ErrFrom: Into<ErrInto>,
{
  fn map_into(self) -> Result<OkInto, ErrInto> {
    self.map(Into::into).map_err(Into::into)
  }
}