Skip to main content

Platform

Enum Platform 

Source
pub enum Platform {
    Github,
    Gitea,
    Gitlab,
    Codeberg,
    Forgejo,
}
Expand description

§Platform

is the main part of grp, this struct allows you to interact with any platform, just by giving a configuration

use grp_core::Platform;
 
let platform = Platform::matches("github");
 
assert!(platform.unwrap() == Platform::Github);

Variants§

§

Github

§

Gitea

§

Gitlab

§

Codeberg

§

Forgejo

Implementations§

Source§

impl Platform

Source

pub fn name(&self) -> &'static str

return the &str name for the repo.

Source

pub fn max_repo_depth(&self) -> usize

Max path depth for a repo

Source§

impl Platform

Source

pub async fn get<U: IntoUrl>( &self, url: U, auth: bool, config: &Config, ) -> Result<Response, Error>

Source

pub async fn post<T, U>( &self, url: U, header: bool, config: &Config, json: &T, ) -> Result<Response, Error>
where U: IntoUrl, T: Serialize + ?Sized,

Source

pub async fn delete<U: IntoUrl>( &self, url: U, config: &Config, ) -> Result<Response, Error>

Source§

impl Platform

Source

pub fn matches(name: &str) -> Result<Platform, Error>

§Return

An enum variant that matches the given &str.

§Error

a grp_core::Error of type grp_core::ErrorType::Unsupported.

Source

pub async fn unwrap<T: Into<String>>( &self, result: Response, base_message: T, config: &Config, context: Context, ) -> Result<String, Error>

this function allows to discern if the platform fails, or success procesing the request.

§Return

a String with the response of the platform only if the response was succesfull.

§Error

a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn create_repo<T: Into<String>, A: Animation + ?Sized>( &self, owner: Option<T>, repo: Repo, config: &Config, animation: &Box<A>, ) -> Result<Repo, Error>

Creates a repository for the given owner in the selected platform.

  • owner: the name or path of the user or org that owns the repo.
  • repo: a grp_core::Repo with the metadata for the new repo.
  • config: a grp_core::Config
  • animation: a struct wich implements the trait grp_core::animation::Animation
§Retuns

a grp_core::Repo with the confirmation from the platform.

#Error a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn delete_repo<T: Into<String>, A: Animation + ?Sized>( &self, owner: T, repo: T, config: &Config, permanent: bool, animation: &Box<A>, ) -> Result<(), Error>

Deletes the repo that its given in the selected platform.

  • owner: the name or path of the user or org of the repo to be deleted.
  • config: a grp_core::Config.
  • permanent: only valid for “Gitlab”, it will mark for deletion and delete permanently that repo.
  • animation: a struct wich implements the trait grp_core::animation::Animation
§Return

() if the delete succed

§Error

a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn list_repos<T: Into<String>, A: Animation + ?Sized>( &self, owner: Option<T>, config: &Config, animation: &Box<A>, ) -> (Vec<Repo>, Option<Error>, Vec<Error>)

list all the repos for the given owner, if not present, returns all the repos for the default user (config).

§Return

a tuple with:

  1. Vec<Repo> a list with the repos
  2. Option<Error> a grp_core::Error containing the detail of the error, if this error is present, the list of repos is empty.
  3. Vec<Error> a list of grp_core::Error that contains a list of errors if something happen during the paggination.
§Why is this?

a better solution with yield is planned, but for know this is the best i could do.

Source

pub fn get_repo( &self, response: Result<String, Error>, ) -> Result<Vec<Repo>, Error>

Source§

impl Platform

Source

pub async fn url_delete_repo<S: AsRef<str>>( &self, owner: &S, repo: &S, endpoint: &S, ) -> String

Source§

impl Platform

Source

pub async fn get_user_type( &self, name: &String, conf: &Config, ) -> Result<UserType, Error>

§Return

a grp_core::structs::UserType containing a grp_core::structs::User with the information.

§Error

a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn get_logged_user(&self, conf: &Config) -> Result<User, Error>

§Return

a the logged user as grp_core::structs::User

§Error

a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn get_logged_orgs(&self, config: &Config) -> Result<Vec<User>, Error>

§Return

a vector of grp_core::structs::User

§Error

a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn create_org<T: Into<String>, A: Animation + ?Sized>( &self, name: T, config: &Config, recursive: bool, animation: &Box<A>, ) -> (Vec<User>, Vec<Error>)

Create a given org for the logged user in the selected platform.

  • name: the name or path of the org to be created.
  • config: a grp_core::Config.
  • recursive: only valid for “Gitlab”, it will create all the groups if they not exist.
  • animation: a struct wich implements the trait grp_core::animation::Animation.
§Returns

a tuple with:

  1. Vec<User>: A list of the created orgs.
  2. Vec<Error>: A list of errors if some org faild to be created.
Source§

impl Platform

Source

pub async fn delete_org<T: Into<String>, A: Animation + ?Sized>( &self, name: T, config: &Config, permanent: bool, animation: &Box<A>, ) -> Result<(), Error>

Deletes the org that its given in the selected platform.

  • name: the name or path of the org of the repo to be deleted.
  • config: a grp_core::Config.
  • permanent: only valid for “Gitlab”, it will mark for deletion and delete permanently that org.
  • animation: a struct wich implements the trait grp_core::animation::Animation
§Return

() if the delete succed

§Error

a grp_core::Error containing the detail of the error.

Source§

impl Platform

Source

pub async fn list_orgs<A: Animation + ?Sized>( &self, config: &Config, animation: &Box<A>, ) -> (Vec<User>, Option<Error>, Vec<Error>)

List all the orgs in wich the logged user is member.

  • config: a grp_core::Config
  • animation: a struct wich implements the trait grp_core::animation::Animation
§Return

a tuple with:

  1. Vec<Repo> a list with the repos
  2. Option<Error> a grp_core::Error containing the detail of the error, if this error is present, the list of repos is empty.
  3. Vec<Error> a list of grp_core::Error that contains a list of errors if something happen during the paggination.
§Why is this?

a better solution with yield is planned, but for know this is the best i could do.

Source

pub fn get_user( &self, response: Result<String, Error>, ) -> Result<Vec<User>, Error>

Trait Implementations§

Source§

impl Clone for Platform

Source§

fn clone(&self) -> Platform

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl PartialEq for Platform

Source§

fn eq(&self, other: &Platform) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Platform

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more