pub struct Paste<'a> {
pub(crate) key: Vec<u8>,
pub(crate) key_base58: &'a str,
pub(crate) pasteid: &'a str,
pub(crate) base_url: &'a str,
}
Expand description
Paste
stores pasteid and key.
Fields§
§key: Vec<u8>
§key_base58: &'a str
§pasteid: &'a str
§base_url: &'a str
Implementations§
Source§impl Paste<'_>
impl Paste<'_>
Sourcepub fn parse_url<'a>(url: &'a str) -> Result<Paste<'a>>
pub fn parse_url<'a>(url: &'a str) -> Result<Paste<'a>>
Parse paste info from an URL.
use fitgirl_decrypt::{Paste, Error};
let url1 = "https://paste.fitgirl-repacks.site/?225484ced69df1d1#SKYwGaZwZmRbN2fR4R9QQJzLTmzpctbDE7kZNpwesRW";
let url2 = "https://paste.fitgirl-repacks.site/?225484ced69df1d1#kWYCcn3qmpehWMMBmZ1NJciKNA6eXfK6LPzwgGXFdJ";
assert!(Paste::parse_url(url1).is_ok());
assert!(matches!(Paste::parse_url(url2), Err(Error::KeyLengthMismatch(31))));
Sourcepub fn try_from_key_and_pasteid<'a>(
key_base58: &'a str,
pasteid: &'a str,
) -> Result<Paste<'a>>
pub fn try_from_key_and_pasteid<'a>( key_base58: &'a str, pasteid: &'a str, ) -> Result<Paste<'a>>
Parse paste info from key_base58 (the url segment after ‘#’) and pasteid.
use fitgirl_decrypt::{Paste, Error};
assert!(
Paste::try_from_key_and_pasteid(
"SKYwGaZwZmRbN2fR4R9QQJzLTmzpctbDE7kZNpwesRW",
"",
)
.is_ok()
);
assert!(
matches!(
Paste::try_from_key_and_pasteid(
"kWYCcn3qmpehWMMBmZ1NJciKNA6eXfK6LPzwgGXFdJ",
"225484ced69df1d1",
),
Err(Error::KeyLengthMismatch(31)),
)
);
Sourcepub fn decrypt(&self, cipher: impl AsRef<CipherInfo>) -> Result<Attachment>
pub fn decrypt(&self, cipher: impl AsRef<CipherInfo>) -> Result<Attachment>
Decrypt paste from CipherInfo
.
Sourcepub fn request(&self) -> Result<CipherInfo>
Available on crate feature ureq
only.
pub fn request(&self) -> Result<CipherInfo>
ureq
only.Get CipherInfo
to decrypt synchronously, with [ureq
].
Sourcepub async fn request_async(&self) -> Result<CipherInfo>
Available on crate feature reqwest
only.
pub async fn request_async(&self) -> Result<CipherInfo>
reqwest
only.Get CipherInfo
to decrypt asynchronously, with [reqwest
].
§NOTE
Because reqwest depends on tokio types, if you are using an async runtime
other than tauri and tokio, try to spawn this inside tokio context.
Also see async_compat
Sourcepub async fn request_async_ny(&self) -> Result<CipherInfo>
Available on crate feature nyquest
only.
pub async fn request_async_ny(&self) -> Result<CipherInfo>
nyquest
only.Get CipherInfo
to decrypt asynchronously, with [nyquest
].
Nyquest can be much more lightweight than [reqwest
], though it’s experimental.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Paste<'a>
impl<'a> RefUnwindSafe for Paste<'a>
impl<'a> Send for Paste<'a>
impl<'a> Sync for Paste<'a>
impl<'a> Unpin for Paste<'a>
impl<'a> UnwindSafe for Paste<'a>
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