Skip to main content

EggfetchClient

Struct EggfetchClient 

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

HTTP client wrapping eggfetch-ffi.

The underlying ClientHandle is shared via Arc<ClientHandleInner> so in-flight spawn_blocking requests extend its lifetime independently of napi-rs finalization order. The raw pointer preserves provenance (no usize ↔ *mut round-trip); the underlying ClientHandle is Send + Sync per eggfetch-ffi documentation.

§Lifetime safety for in-flight requests

Each request clones the Arc into its 'static future before entering spawn_blocking. Drop for ClientHandleInner frees the FFI handle only when the last clone (client plus all in-flight requests) is dropped, so a JS garbage-collection of the client object cannot free the handle underneath a running request. Do not replace this with a pattern that frees the handle from Drop for EggfetchClient directly without holding the shared Arc alive in the future.

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.

The optional body is UTF-8 text only; arbitrary binary payloads (interior NUL) are rejected with an error. Use a byte-oriented API for binary uploads.

§Errors

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

Trait Implementations§

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