Enum Expandable

Source
pub enum Expandable<T: Object> {
    Id(T::Id),
    Object(Box<T>),
}
Expand description

An id or object.

By default stripe will return an id for most fields, but if more detail is necessary the expand parameter can be provided to ask for the id to be loaded as an object instead.

For more details see https://stripe.com/docs/api/expanding_objects.

Variants§

§

Id(T::Id)

Just the object id.

§

Object(Box<T>)

The entire object.

Implementations§

Source§

impl<T: Object> Expandable<T>

Source

pub fn is_object(&self) -> bool

Returns true if we have the object.

Source

pub fn as_object(&self) -> Option<&T>

If the Expandable is an object, return that, otherwise return None.

Source

pub fn into_object(self) -> Option<T>

If the Expandable is an object, return that by taking ownership, otherwise return None.

Source

pub fn into_id(self) -> T::Id

Take ownership of the object’s id.

Source

pub fn id(&self) -> &T::Id

Extract the object’s id.

Trait Implementations§

Source§

impl<T: Clone + Object> Clone for Expandable<T>
where T::Id: Clone,

Source§

fn clone(&self) -> Expandable<T>

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<T: Debug + Object> Debug for Expandable<T>
where T::Id: Debug,

Source§

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

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

impl<T: Object> Default for Expandable<T>
where T::Id: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Deserialize for Expandable<T>

Source§

fn begin(out: &mut Option<Self>) -> &mut dyn Visitor

The only correct implementation of this method is: Read more
Source§

impl<T> Serialize for Expandable<T>
where T: Serialize + Object, T::Id: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Expandable<T>
where <T as Object>::Id: Freeze,

§

impl<T> RefUnwindSafe for Expandable<T>
where <T as Object>::Id: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T> Send for Expandable<T>
where <T as Object>::Id: Send, T: Send,

§

impl<T> Sync for Expandable<T>
where <T as Object>::Id: Sync, T: Sync,

§

impl<T> Unpin for Expandable<T>
where <T as Object>::Id: Unpin,

§

impl<T> UnwindSafe for Expandable<T>
where <T as Object>::Id: UnwindSafe, T: UnwindSafe,

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, 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> 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.