Skip to main content

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, ArgInfoTables), ) -> Self

Function to register the enum with PHP, called once it is built.

See ClassBuilder::registration for the ownership contract of the argument info tables.

§Parameters
  • register - The function to call to register the enum.
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 called outside a module startup (MINIT) function.
  • If the registration function was not set prior to calling this method.
§Errors

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 = !

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.