Skip to main content

EggfetchClient

Struct EggfetchClient 

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

HTTP client wrapping eggfetch-ffi.

The client pointer is stored as a [SendClientPtr] raw-pointer wrapper to satisfy napi’s Send requirement for async futures while preserving pointer provenance (no usize ↔ *mut round-trip). The underlying ClientHandle is Send + Sync per eggfetch-ffi documentation.

§Lifetime safety for in-flight requests

Copying the raw pointer into a 'static future is safe here because of how napi-rs (2.x) generates async class methods: before launching the future it creates a strong napi_ref (refcount 1) on this (napi_create_reference) and releases it only when the future resolves (see napi-derive-backend codegen, NapiRefContainer). A strong reference prevents garbage collection and finalization of the JS object, so Drop for EggfetchClient cannot free the FFI handle while any request future is outstanding. Do not replace this with a pattern that frees the handle independently of napi’s reference tracking without adding an equivalent guard.

This remains an experimental prototype (see lib.rs): requests execute through the synchronous C ABI inside spawn_blocking.

Implementations§

Source§

impl EggfetchClient

Source

pub fn instance_of<V: NapiRaw>(env: Env, value: V) -> Result<bool>

Source§

impl EggfetchClient

Source§

impl EggfetchClient

Source

pub fn new() -> Result<Self>

Create a new client with default settings.

§Errors

Returns an error if the underlying FFI client allocation fails.

Source

pub async fn get(&self, url: String) -> Result<EggfetchResponse>

Send a GET request and return the response.

§Errors

Returns an error if the request fails or the URL is invalid.

Source

pub async fn post( &self, url: String, body: Option<String>, ) -> Result<EggfetchResponse>

Send a POST request with optional body.

§Errors

Returns an error if the request fails or the URL/body is invalid.

Source

pub async fn put( &self, url: String, body: Option<String>, ) -> Result<EggfetchResponse>

Send a PUT request with optional body.

§Errors

Returns an error if the request fails or the URL/body is invalid.

Source

pub async fn patch( &self, url: String, body: Option<String>, ) -> Result<EggfetchResponse>

Send a PATCH request with optional body.

§Errors

Returns an error if the request fails or the URL/body is invalid.

Source

pub async fn delete(&self, url: String) -> Result<EggfetchResponse>

Send a DELETE request.

§Errors

Returns an error if the request fails or the URL is invalid.

Source

pub async fn head(&self, url: String) -> Result<EggfetchResponse>

Send a HEAD request.

§Errors

Returns an error if the request fails or the URL is invalid.

Source

pub async fn options(&self, url: String) -> Result<EggfetchResponse>

Send an OPTIONS request.

§Errors

Returns an error if the request fails or the URL is invalid.

Source

pub async fn request( &self, method: String, url: String, body: Option<String>, ) -> Result<EggfetchResponse>

Send a request with a custom method.

§Errors

Returns an error if the request fails or the method/URL is invalid.

Trait Implementations§

Source§

impl Drop for EggfetchClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl FromNapiMutRef for EggfetchClient

Source§

unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>

Safety Read more
Source§

impl FromNapiRef for EggfetchClient

Source§

unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>

Safety Read more
Source§

impl FromNapiValue for &EggfetchClient

Source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
Source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

Source§

impl FromNapiValue for &mut EggfetchClient

Source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
Source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

Source§

impl ObjectFinalize for EggfetchClient

Source§

fn finalize(self, env: Env) -> Result<(), Error>

Source§

impl ToNapiValue for EggfetchClient

Source§

impl TypeName for EggfetchClient

Source§

impl TypeName for &EggfetchClient

Source§

impl TypeName for &mut EggfetchClient

Source§

impl ValidateNapiValue for &EggfetchClient

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more
Source§

impl ValidateNapiValue for &mut EggfetchClient

Source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> JsValuesTupleIntoVec for T
where T: ToNapiValue,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more