Skip to main content

GithubHandle

Struct GithubHandle 

Source
pub struct GithubHandle(/* private fields */);
Available on crate feature github only.
Expand description

A GitHub handle (aka username).

Contains 1–39 ASCII letters, digits, or single interior hyphens. Enterprise Managed Users may additionally have an _ followed by a 3–8 character alphanumeric enterprise shortcode. GitHub’s current and legacy-compatible ceiling is 39 characters (30 for some data-residency managed users). Parsing drops one optional @ and preserves spelling; equality, ordering, and hashing ignore ASCII case.

See https://docs.github.com/en/enterprise-cloud@latest/admin/managing-iam/iam-configuration-reference/username-considerations-for-external-authentication.

use known_types_github::GithubHandle;

let managed: GithubHandle = "@The-Octocat_octo".parse()?;
assert_eq!(managed.as_str(), "The-Octocat_octo");
assert!("octo--cat".parse::<GithubHandle>().is_err());

See the shared handle contract for conversion and integration behavior. With async-graphql, the scalar is named GithubHandle.

Implementations§

Source§

impl GithubHandle

Source

pub const MIN_LENGTH: usize = 1

Minimum length of the normalized handle, in Unicode scalar values.

Source

pub const MAX_LENGTH: usize = 39

Maximum representational length, in Unicode scalar values.

This is the widest known current or historical upstream bound, not necessarily the current registration limit.

Source

pub fn as_str(&self) -> &str

Borrow the validated, normalized handle.

Source

pub fn into_string(self) -> String

Consume the handle and return its stored spelling.

Trait Implementations§

Source§

impl AsRef<String> for GithubHandle

Source§

fn as_ref(&self) -> &String

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for GithubHandle

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for GithubHandle

Source§

fn clone(&self) -> GithubHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CursorType for GithubHandle

Available on crate feature async-graphql only.
Source§

type Error = ParseHandleError

Error type for decode_cursor.
Source§

fn decode_cursor( input: &str, ) -> Result<GithubHandle, <GithubHandle as CursorType>::Error>

Decode cursor from string.
Source§

fn encode_cursor(&self) -> String

Encode cursor to string.
Source§

impl Debug for GithubHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'r, DB> Decode<'r, DB> for GithubHandle
where DB: Database, String: Decode<'r, DB>,

Available on crate feature sqlx only.
Source§

fn decode( value: <DB as Database>::ValueRef<'r>, ) -> Result<GithubHandle, Box<dyn Error + Send + Sync>>

Decode a new value of this type using a raw value from the database.
Source§

impl<'de> Deserialize<'de> for GithubHandle

Available on crate feature serde only.
Source§

fn deserialize<D>( deserializer: D, ) -> Result<GithubHandle, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for GithubHandle

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'q, DB> Encode<'q, DB> for GithubHandle
where DB: Database, String: Encode<'q, DB>,

Available on crate feature sqlx only.
Source§

fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Send + Sync>>

Writes the value of self into buf without moving self. Read more
Source§

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Source§

fn size_hint(&self) -> usize

Source§

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Send + Sync>>
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Source§

impl Eq for GithubHandle

Source§

impl From<GithubHandle> for SocialHandle

Source§

fn from(value: GithubHandle) -> Self

Converts to this type from the input type.
Source§

impl FromStr for GithubHandle

Source§

type Err = ParseHandleError

The associated error which can be returned from parsing.
Source§

fn from_str(input: &str) -> Result<GithubHandle, <GithubHandle as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for GithubHandle

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl InputType for GithubHandle

Source§

type RawValueType = GithubHandle

The raw type used for validator. Read more
Source§

fn type_name() -> Cow<'static, str>

Type the name.
Source§

fn create_type_info(registry: &mut Registry) -> String

Create type information in the registry and return qualified typename.
Source§

fn parse( value: Option<ConstValue>, ) -> Result<GithubHandle, InputValueError<GithubHandle>>

Parse from Value. None represents undefined.
Source§

fn to_value(&self) -> ConstValue

Convert to a Value for introspection.
Source§

fn as_raw_value(&self) -> Option<&<GithubHandle as InputType>::RawValueType>

Returns a reference to the raw value.
Source§

fn qualified_type_name() -> String

Qualified typename.
Source§

impl Ord for GithubHandle

Source§

fn cmp(&self, other: &GithubHandle) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl OutputType for GithubHandle

Source§

fn type_name() -> Cow<'static, str>

Type the name.
Source§

fn create_type_info(registry: &mut Registry) -> String

Create type information in the registry and return qualified typename.
Source§

async fn resolve( &self, _: &ContextBase<'_, &Positioned<SelectionSet>>, _field: &Positioned<Field>, ) -> Result<ConstValue, ServerError>

Available on non-crate feature boxed-trait only.
Resolve an output value to async_graphql::Value.
Source§

fn qualified_type_name() -> String

Qualified typename.
Source§

fn introspection_type_name(&self) -> Cow<'static, str>

Introspection type name Read more
Source§

impl PartialEq for GithubHandle

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for GithubHandle

Source§

fn partial_cmp(&self, other: &GithubHandle) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ScalarType for GithubHandle

Source§

fn parse( value: ConstValue, ) -> Result<GithubHandle, InputValueError<GithubHandle>>

Parse a scalar value.
Source§

fn is_valid(value: &ConstValue) -> bool

Checks for a valid scalar value. Read more
Source§

fn to_value(&self) -> ConstValue

Convert the scalar to Value.
Source§

impl Serialize for GithubHandle

Available on crate feature serde only.
Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&str> for GithubHandle

Source§

type Error = ParseHandleError

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

fn try_from( input: &str, ) -> Result<GithubHandle, <GithubHandle as TryFrom<&str>>::Error>

Performs the conversion.
Source§

impl TryFrom<String> for GithubHandle

Source§

type Error = ParseHandleError

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

fn try_from( input: String, ) -> Result<GithubHandle, <GithubHandle as TryFrom<String>>::Error>

Performs the conversion.
Source§

impl<DB> Type<DB> for GithubHandle
where DB: Database, String: Type<DB>,

Available on crate feature sqlx only.
Source§

fn type_info() -> <DB as Database>::TypeInfo

Returns the canonical SQL type for this Rust type. Read more
Source§

fn compatible(ty: &<DB as Database>::TypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> RpcMessage for T
where T: Debug + Serialize + DeserializeOwned + Send + Sync + Unpin + 'static,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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