Skip to main content

FieldsDecl

Struct FieldsDecl 

Source
pub struct FieldsDecl { /* private fields */ }
Expand description

A value-form expansion: the accessor whose returned struct supplies the fields, plus the per-field adjustments. Built with fields! and handed to ExpandReturnDecl::fields.

Both adjusters key on the Rust struct field name, mirroring FunctionDecl::expand_param’s Rust-parameter-name key: an unknown field name or a repeated one is a hard error, so a field renamed upstream is caught rather than silently ignored.

Implementations§

Source§

impl FieldsDecl

Source

pub fn new(func: Ident) -> Self

Source

pub fn func(&self) -> &Ident

The value-form accessor’s ident, as declared with fields!.

Source

pub fn overrides(&self) -> &[(String, ExpandReturnDecl)]

The per-field decomposition overrides, in declaration order.

Source

pub fn names(&self) -> &[(String, String)]

The per-field name overrides, in declaration order.

Source

pub fn is_consuming(&self) -> bool

Whether the accessor consumes its receiver (set by ExpandReturnDecl::fields_self_into). Named is_consuming rather than consuming — that name is already the crate-internal builder method that sets the flag.

Source

pub fn field(self, field: impl AsRef<str>, decl: ExpandReturnDecl) -> Self

Replace one field’s decomposition, with the same ExpandReturnDecl a type-level default uses — so the complete-set rule applies here too: the decl states that field’s entire leaf set. Use it where the field’s type default is not what this boundary wants (a lone .field_self() keeps the raw handle instead of decomposing it).

An override declaring no records states an empty leaf set: the field does not cross. That is the one way to drop a field a value form carries, and it follows from the complete-set rule rather than adding a rule — a boundary that wants none of a field’s leaves says so the same way it says it wants some of them. (A generator-level expand_return!(T) with no records is still an error: a type has to cross somehow.) Use it for a field the binding has no surface for — diagnostics a consumer never reads, a type whose accessors would drag in a subtree nothing asks for:

prebindgen_registry::expand_return!(Sample).fields_self_into(
    prebindgen_registry::fields!(sample_into_struct)
        .field("timestamp_stack", prebindgen_registry::expand_return!(TimestampStack)),
);
Source

pub fn name( self, field: impl AsRef<str>, kotlin_name: impl Into<String>, ) -> Self

Rename one field’s leaf, overriding the name derived from the struct field ident. The literal Kotlin name, like fun!(f).name(...).

Trait Implementations§

Source§

impl Clone for FieldsDecl

Source§

fn clone(&self) -> FieldsDecl

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

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