Struct noxious_client::Proxy [−][src]
A proxy object returned by the Client
.
To manipulate this proxy and manipulate the toxics, you can call methods on
this object.
Fields
config: ProxyConfig
Contains the proxy listen and upstream address, name. You can mutate them
and call .save()
to update the proxy.
Implementations
impl Proxy
[src]
pub async fn save(&mut self) -> Result<(), ClientError>
[src]
Save saves changes to a proxy such as its enabled status or upstream port. Note: this does not update the toxics
pub async fn enable(&mut self) -> Result<(), ClientError>
[src]
Enable a proxy again after it has been disabled
pub async fn disable(&mut self) -> Result<(), ClientError>
[src]
Disable a proxy so that no connections can pass through. This will drop all active connections.
pub fn is_enabled(&self) -> bool
[src]
Returns whether this proxy is enabled or not
pub async fn change_name(&mut self, new_name: &str) -> Result<(), ClientError>
[src]
Give this proxy a new name, save it.
pub async fn delete(self) -> Result<(), ClientError>
[src]
Delete a proxy complete and close all existing connections through it. All information about
the proxy such as listen port and active toxics will be deleted as well. If you just wish to
stop and later enable a proxy, use enable()
and disable()
.
pub async fn toxics(&self) -> Result<Vec<Toxic>, ClientError>
[src]
Returns a map of all active toxics and their attributes
pub async fn add_toxic(&self, toxic: &Toxic) -> Result<Toxic, ClientError>
[src]
Add a new toxic to this proxy.
Example
use noxious_client::{Client, Toxic, ToxicKind, StreamDirection}; #[tokio::main] async fn main() { let toxic = Toxic { kind: ToxicKind::Latency { latency: 40, jitter: 5 }, name: "myProxy_latency".to_owned(), toxicity: 0.9, direction: StreamDirection::Upstream, }; let client = Client::new("127.0.0.1:8474"); let result = client.add_toxic(&toxic).await; }
pub async fn update_toxic(
&self,
name: &str,
toxicity: f32,
kind: ToxicKind,
direction: StreamDirection
) -> Result<Toxic, ClientError>
[src]
&self,
name: &str,
toxicity: f32,
kind: ToxicKind,
direction: StreamDirection
) -> Result<Toxic, ClientError>
Updates a toxic with the given name If toxicity is below zero, it will be sent as 0
pub async fn remove_toxic(&self, name: &str) -> Result<(), ClientError>
[src]
Removes a toxic with the given name
Trait Implementations
impl Clone for Proxy
[src]
impl Debug for Proxy
[src]
impl PartialEq<Proxy> for Proxy
[src]
impl StructuralPartialEq for Proxy
[src]
Auto Trait Implementations
impl RefUnwindSafe for Proxy
impl Send for Proxy
impl Sync for Proxy
impl Unpin for Proxy
impl UnwindSafe for Proxy
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,