[][src]Struct j4rs::Jvm

pub struct Jvm { /* fields omitted */ }

Holds the assets for the JVM

Implementations

impl Jvm[src]

pub fn new(
    jvm_options: &[String],
    lib_name_to_load: Option<String>
) -> Result<Jvm>
[src]

Creates a new Jvm.

pub fn attach_thread() -> Result<Jvm>[src]

Attaches the current thread to an active JavaVM

pub fn attach_thread_with_no_detach_on_drop() -> Result<Jvm>[src]

Attaches the current thread to an active JavaVM and instructs that the Jvm will detach the Java JVM from the thread when the rust Jvm is dropped.

This is useful when creating a Jvm while on a Thread that is created in the Java world. When this Jvm is dropped, we don't want to detach the thread from the Java VM.

pub fn detach_thread_on_drop(&mut self, detach: bool)[src]

If false, the thread will not be detached when the Jvm is being dropped. This is useful when creating a Jvm while on a Thread that is created in the Java world. When this Jvm is dropped, we don't want to detach the thread from the Java VM.

It prevents errors like: attempting to detach while still running code

pub fn try_from(jni_environment: *mut JNIEnv) -> Result<Jvm>[src]

pub fn create_instance(
    &self,
    class_name: &str,
    inv_args: &[InvocationArg]
) -> Result<Instance>
[src]

Creates an Instance of the class class_name, passing an array of InvocationArgs to construct the instance.

pub fn static_class(&self, class_name: &str) -> Result<Instance>[src]

Retrieves the static class class_name.

pub fn create_java_array(
    &self,
    class_name: &str,
    inv_args: &[InvocationArg]
) -> Result<Instance>
[src]

Creates a new Java Array with elements of the class class_name. The array will have the InvocationArgs populated. The InvocationArgs must be of type class_name.

pub fn create_java_list(
    &self,
    class_name: &str,
    inv_args: &[InvocationArg]
) -> Result<Instance>
[src]

Creates a new Java List with elements of the class class_name. The array will have the InvocationArgs populated. The InvocationArgs must be of type class_name.

pub fn invoke(
    &self,
    instance: &Instance,
    method_name: &str,
    inv_args: &[InvocationArg]
) -> Result<Instance>
[src]

Invokes the method method_name of a created Instance, passing an array of InvocationArgs. It returns an Instance as the result of the invocation.

pub fn field(&self, instance: &Instance, field_name: &str) -> Result<Instance>[src]

Retrieves the field field_name of a created Instance.

pub fn static_class_field(
    &self,
    class_name: &str,
    field_name: &str
) -> Result<Instance>
[src]

Retrieves the field field_name of a static class.

pub fn invoke_to_channel(
    &self,
    instance: &Instance,
    method_name: &str,
    inv_args: &[InvocationArg]
) -> Result<InstanceReceiver>
[src]

Invokes the method method_name of a created Instance, passing an array of InvocationArgs. It returns a Result of InstanceReceiver that may be used to get an underlying Receiver<Instance>. The result of the invocation will come via this Receiver.

pub fn init_callback_channel(
    &self,
    instance: &Instance
) -> Result<InstanceReceiver>
[src]

Initializes a callback channel via a Java Instance that is a NativeCallbackToRustChannelSupport. It returns a Result of InstanceReceiver that may be used to get an underlying Receiver<Instance>. The NativeCallbackToRustChannelSupport Instance which is passed as argument, will be sending Instances via this Receiver.

pub fn invoke_static(
    &self,
    class_name: &str,
    method_name: &str,
    inv_args: &[InvocationArg]
) -> Result<Instance>
[src]

Invokes the static method method_name of the class class_name, passing an array of InvocationArgs. It returns an Instance as the result of the invocation.

pub fn clone_instance(&self, instance: &Instance) -> Result<Instance>[src]

Creates a clone of the provided Instance

pub fn cast(&self, from_instance: &Instance, to_class: &str) -> Result<Instance>[src]

Invokes the static method method_name of the class class_name, passing an array of InvocationArgs. It returns an Instance as the result of the invocation.

pub fn to_rust_boxed<T>(&self, instance: Instance) -> Result<Box<T>> where
    T: DeserializeOwned + Any
[src]

Returns the Rust representation of the provided instance, boxed

pub fn to_rust<T>(&self, instance: Instance) -> Result<T> where
    T: DeserializeOwned + Any
[src]

Returns the Rust representation of the provided instance

pub fn to_rust_deserialized<T>(&self, instance: Instance) -> Result<T> where
    T: DeserializeOwned + Any
[src]

pub fn deploy_artifact<T: Any + JavaArtifact>(&self, artifact: &T) -> Result<()>[src]

Deploys an artifact in the default j4rs jars location.

This is useful for build scripts that need jars for the runtime that can be downloaded from e.g. Maven.

The function deploys only the specified artifact, not its transitive dependencies.

pub fn copy_j4rs_libs_under(path: &str) -> Result<()>[src]

Copies the jassets default directory and the j4rs dynamic library under the specified location. This is useful for cases when with_base_path method is used when building a Jvm with the JvmBuilder. Build scripts should use this method.

pub fn chain(&self, instance: &Instance) -> Result<ChainableInstance<'_>>[src]

Initiates a chain of operations on Instances.

pub fn into_chain(&self, instance: Instance) -> ChainableInstance<'_>[src]

Initiates a chain of operations on Instances.

pub fn throw_invocation_exception(&self, message: &str) -> Result<()>[src]

Throws an exception in the Java World

pub fn select(
    instance_receivers: &[&InstanceReceiver]
) -> Result<(usize, Instance)>
[src]

Returns the first Instance that is available from the passed InstanceReceivers, along with the index of the receiver that was selected and actually returned the instance.

This is a mostly naive implementation of select, because of absence for selecting among mpsc channels.

pub fn select_timeout(
    instance_receivers: &[&InstanceReceiver],
    timeout: &Duration
) -> Result<(usize, Instance)>
[src]

Returns the first Instance that is available from the passed InstanceReceivers, along with the index of the receiver that was selected and actually returned the instance.

If there are no instances returned for the duration defined in timeout argument, an error is returned.

This is a mostly naive implementation of select, because of absence for selecting among mpsc channels.

Trait Implementations

impl Clone for Jvm[src]

impl Drop for Jvm[src]

impl JavaFxSupport for Jvm[src]

fn start_javafx_app(&self) -> Result<InstanceReceiver>[src]

Triggers the start of a JavaFX application. When the JavaFX application starts, the InstanceReceiver channel will receive an Instance of javafx.stage.Stage.

The UI may start being built using the provided Stage

fn get_javafx_event_receiver(
    &self,
    instance: &Instance,
    fx_event_type: FxEventType
) -> Result<InstanceReceiver>
[src]

Creates an instance receiver that will be receiving Instances of events. The fx_event_type argument is the type of the event that we want to handle and receive Instances for.

For example, to create an InstanceReceiver for a 'javafx.scene.control.Button', you need to call the method by using the button as the instance argument FxEventType::ActionEvent_Action as the fx_event_type argument

fn on_close_event_receiver(&self, stage: &Instance) -> Result<InstanceReceiver>[src]

Creates an instance receiver that will be receiving Instances of events for onclose requests of a Stage.

The instance passed as argument needs to be of class javafx.stage.Stage.

fn deploy_javafx_dependencies(&self) -> Result<()>[src]

Deploys the required dependencies to run a JavaFX application in order to be able to be used by j4rs.

Auto Trait Implementations

impl RefUnwindSafe for Jvm

impl !Send for Jvm

impl !Sync for Jvm

impl Unpin for Jvm

impl UnwindSafe for Jvm

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.