Struct Processor
pub struct Processor { /* private fields */ }
Expand description
Transforms cookies before they are sent to the client, or after they have been parsed from an incoming request.
§Creating a Processor
A processor is created from a ProcessorConfig
using the From
trait.
use biscotti::{Processor, ProcessorConfig, Key};
use biscotti::config::{CryptoRule, CryptoAlgorithm};
let mut config = ProcessorConfig::default();
config.crypto_rules.push(CryptoRule {
cookie_names: vec!["session".to_string()],
algorithm: CryptoAlgorithm::Encryption,
// You'll use a key loaded from *somewhere* in production—e.g.
// from a file, environment variable, or a secret management service.
key: Key::generate(),
fallbacks: vec![],
});
let processor: Processor = config.into();
§Using a Processor
You need a Processor
to invoke ResponseCookies::header_values
and RequestCookies::parse_header
.
You can also use it to transform individual cookies using
Processor::process_outgoing
and Processor::process_incoming
.
Implementations§
§impl Processor
impl Processor
pub fn process_outgoing<'c>(
&self,
cookie: ResponseCookie<'c>,
) -> ResponseCookie<'c>
pub fn process_outgoing<'c>( &self, cookie: ResponseCookie<'c>, ) -> ResponseCookie<'c>
Transform a ResponseCookie
before it is sent to the client.
pub fn process_incoming<'c>(
&self,
name: &'c str,
value: &'c str,
) -> Result<RequestCookie<'c>, ProcessIncomingError>
pub fn process_incoming<'c>( &self, name: &'c str, value: &'c str, ) -> Result<RequestCookie<'c>, ProcessIncomingError>
Transform a RequestCookie
before it is added to ResponseCookies
.
Trait Implementations§
§impl From<ProcessorConfig> for Processor
impl From<ProcessorConfig> for Processor
§fn from(value: ProcessorConfig) -> Processor
fn from(value: ProcessorConfig) -> Processor
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Processor
impl RefUnwindSafe for Processor
impl Send for Processor
impl Sync for Processor
impl Unpin for Processor
impl UnwindSafe for Processor
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)