pub struct Context { /* private fields */ }
Expand description
A context stores a source endpoint, a process info and other any values during connecting.
Implementations§
Source§impl Context
impl Context
Sourcepub fn from_socketaddr(addr: SocketAddr) -> Context
pub fn from_socketaddr(addr: SocketAddr) -> Context
new a context from socket addr
Sourcepub fn insert<I: Serialize>(&mut self, key: String, value: I) -> Result<()>
pub fn insert<I: Serialize>(&mut self, key: String, value: I) -> Result<()>
Inserts a key-value pair into the context.
Sourcepub fn remove<T: DeserializeOwned>(&mut self, key: &str) -> Result<()>
pub fn remove<T: DeserializeOwned>(&mut self, key: &str) -> Result<()>
Removes a key from the context
Sourcepub fn get<T: DeserializeOwned>(&self, key: &str) -> Result<T>
pub fn get<T: DeserializeOwned>(&self, key: &str) -> Result<T>
Returns a value corresponding to the key.
Sourcepub fn insert_value(&mut self, key: String, value: Value)
pub fn insert_value(&mut self, key: String, value: Value)
Inserts a key-value pair into the context.
Sourcepub fn remove_value(&mut self, key: &str) -> Result<()>
pub fn remove_value(&mut self, key: &str) -> Result<()>
Removes a key from the context, returning the value at the key if the key was previously in the context.
Sourcepub fn insert_common<T: CommonField>(&mut self, value: T) -> Result<()>
pub fn insert_common<T: CommonField>(&mut self, value: T) -> Result<()>
Inserts a key-value pair into the context.
Sourcepub fn get_common<T: CommonField>(&self) -> Result<T>
pub fn get_common<T: CommonField>(&self) -> Result<T>
Returns a value corresponding to the key.
Sourcepub fn append_composite(&mut self, composite_name: impl Into<String>)
pub fn append_composite(&mut self, composite_name: impl Into<String>)
Add composite to composite_list
Sourcepub fn composite_list(&self) -> &Vec<String>
pub fn composite_list(&self) -> &Vec<String>
Get composite_list
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more