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 Config
using the From
trait.
use biscotti::{Processor, Key};
use biscotti::config::{Config, CryptoRule, CryptoType};
let mut config = Config::default();
config.crypto_rules.push(CryptoRule {
cookie_names: vec!["session".to_string()],
r#type: CryptoType::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(),
secondary_keys: 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§
source§impl Processor
impl Processor
sourcepub 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.
sourcepub 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§
Auto Trait Implementations§
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