MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / get

Method get

CedarJavaFFI/src/jlist.rs:72–88  ·  view source on GitHub ↗

Get the object at position `i`, throws an exception if out-of-bounds

(&self, env: &mut JNIEnv<'a>, i: i32)

Source from the content-addressed store, hash-verified

70
71 /// Get the object at position `i`, throws an exception if out-of-bounds
72 pub fn get(&self, env: &mut JNIEnv<'a>, i: i32) -> Result<T> {
73 let v = env.call_method(
74 &self.obj,
75 "get",
76 "(I)Ljava/lang/Object;",
77 &[JValueGen::Int(i)],
78 )?;
79 // `.get()` throws on index out of bounds
80 if env.exception_check()? {
81 Err(Box::new(InternalJNIError::IndexOutOfBounds {
82 len: self.size,
83 idx: i,
84 }))
85 } else {
86 T::cast(env, get_object_ref(v)?)
87 }
88 }
89
90 /// Iterate over the elements in the list
91 pub fn iter(&self, env: &mut JNIEnv<'a>) -> Result<impl Iterator<Item = T>> {

Callers 5

iterMethod · 0.45
jstr_list_to_rust_vecFunction · 0.45

Calls 1

get_object_refFunction · 0.85