Struct Paste

Source
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<'_>

Source

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))));
Source

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)),
    )
);
Source

pub fn decrypt(&self, cipher: impl AsRef<CipherInfo>) -> Result<Attachment>

Decrypt paste from CipherInfo.

Source

pub fn request(&self) -> Result<CipherInfo>

Available on crate feature ureq only.

Get CipherInfo to decrypt synchronously, with [ureq].

Source

pub async fn request_async(&self) -> Result<CipherInfo>

Available on crate feature 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

Source

pub async fn request_async_ny(&self) -> Result<CipherInfo>

Available on crate feature nyquest only.

Get CipherInfo to decrypt asynchronously, with [nyquest].

Nyquest can be much more lightweight than [reqwest], though it’s experimental.

Trait Implementations§

Source§

impl<'a> Clone for Paste<'a>

Source§

fn clone(&self) -> Paste<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Paste<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T