EnumBuilder

Struct EnumBuilder 

Source
pub struct EnumBuilder { /* private fields */ }
Available on crate feature enum only.
Expand description

A builder for PHP enums.

Implementations§

Source§

impl EnumBuilder

Source

pub fn new<T: Into<String>>(name: T) -> Self

Creates a new enum builder with the given name.

Source

pub fn case(self, case: &'static EnumCase) -> Self

Adds an enum case to the enum.

§Panics

If the case’s data type does not match the enum’s data type

Source

pub fn method( self, method: FunctionBuilder<'static>, flags: MethodFlags, ) -> Self

Adds a method to the enum.

Source

pub fn registration(self, register: fn(&'static mut ClassEntry)) -> Self

Function to register the class with PHP. This function is called after the class is built.

§Parameters
  • register - The function to call to register the class.
Source

pub fn docs(self, docs: DocComments) -> Self

Add documentation comments to the enum.

Source

pub fn register(self) -> Result<()>

Registers the enum with PHP.

§Panics

If the registration function was not set prior to calling this method.

§Errors

If the enum could not be registered, e.g. due to an invalid name or data type.

Trait Implementations§

Source§

impl From<EnumBuilder> for Enum

Source§

fn from(val: EnumBuilder) -> Self

Converts to this type from the input type.

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