Struct noak::writer::ClassWriter

source ·
pub struct ClassWriter<State: State> { /* private fields */ }
Expand description

A class writer can build a class.

§Examples

use noak::writer::ClassWriter;
use noak::{AccessFlags, Version};

let buf = ClassWriter::new()
    .version(Version::latest())?
    .access_flags(AccessFlags::PUBLIC | AccessFlags::SUPER)?
    .this_class("com/example/Example")?
    .super_class("java/lang/Object")?
    .interfaces(|_interfaces| Ok(()))?
    .fields(|_fields| Ok(()))?
    .methods(|_methods| Ok(()))?
    .attributes(|attributes| {
        attributes.begin(|attribute| attribute.source_file("Example.java"))?;
        Ok(())
    })?
    .into_bytes()?;

Implementations§

source§

impl ClassWriter<Start>

source

pub fn new() -> ClassWriter<Start>

Creates a new class writer with a sensitive initial capacity.

source

pub fn version( self, version: Version ) -> Result<ClassWriter<AccessFlags>, EncodeError>

source§

impl ClassWriter<AccessFlags>

source

pub fn access_flags( self, flags: AccessFlags ) -> Result<ClassWriter<ThisClass>, EncodeError>

source§

impl ClassWriter<ThisClass>

source

pub fn this_class<I>( self, name: I ) -> Result<ClassWriter<SuperClass>, EncodeError>
where I: Insertable<Class>,

source§

impl ClassWriter<SuperClass>

source

pub fn super_class<I>( self, name: I ) -> Result<ClassWriter<Interfaces>, EncodeError>
where I: Insertable<Class>,

source

pub fn no_super_class(self) -> Result<ClassWriter<Interfaces>, EncodeError>

source§

impl ClassWriter<Interfaces>

source

pub fn interfaces<F>(self, f: F) -> Result<ClassWriter<Fields>, EncodeError>
where F: FnOnce(&mut ManyWriter<InterfaceWriter<Start>, u16>) -> Result<(), EncodeError>,

source§

impl ClassWriter<Fields>

source

pub fn fields<F>(self, f: F) -> Result<ClassWriter<Methods>, EncodeError>
where F: FnOnce(&mut ManyWriter<FieldWriter<AccessFlags>, u16>) -> Result<(), EncodeError>,

source§

impl ClassWriter<Methods>

source

pub fn methods<F>(self, f: F) -> Result<ClassWriter<Attributes>, EncodeError>
where F: FnOnce(&mut ManyWriter<MethodWriter<AccessFlags>, u16>) -> Result<(), EncodeError>,

source§

impl ClassWriter<Attributes>

source

pub fn attributes<F>(self, f: F) -> Result<ClassWriter<End>, EncodeError>
where F: FnOnce(&mut ManyWriter<AttributeWriter<ClassWriter<Attributes>, Start>, u16>) -> Result<(), EncodeError>,

source§

impl ClassWriter<End>

source

pub fn into_bytes(self) -> Result<Vec<u8>, EncodeError>

source

pub fn write_bytes_to<W: Write>(&self, writer: &mut W) -> Result<()>

Trait Implementations§

source§

impl<State: Clone + State> Clone for ClassWriter<State>

source§

fn clone(&self) -> ClassWriter<State>

Returns a copy 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<State: State> Debug for ClassWriter<State>

source§

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

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

impl Default for ClassWriter<Start>

source§

fn default() -> ClassWriter<Start>

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

impl<State: State> EncoderContext for ClassWriter<State>

source§

fn insert_constant<I: Into<Item>>( &mut self, item: I ) -> Result<Index<I>, EncodeError>

Auto Trait Implementations§

§

impl<State> Freeze for ClassWriter<State>
where State: Sealed,

§

impl<State> RefUnwindSafe for ClassWriter<State>
where State: Sealed + RefUnwindSafe,

§

impl<State> Send for ClassWriter<State>
where State: Sealed + Send,

§

impl<State> Sync for ClassWriter<State>
where State: Sealed + Sync,

§

impl<State> Unpin for ClassWriter<State>
where State: Sealed + Unpin,

§

impl<State> UnwindSafe for ClassWriter<State>
where State: Sealed + 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> 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,

§

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

§

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

§

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.