Make the /resolve_magnet HTTP endpoint return an actual torrent file, not info
This commit is contained in:
parent
cd0f38f0fb
commit
d54b67d2dc
6 changed files with 132 additions and 23 deletions
28
crates/bencode/src/raw_value.rs
Normal file
28
crates/bencode/src/raw_value.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use serde::Serialize;
|
||||
|
||||
pub struct RawValue<T>(pub T);
|
||||
|
||||
pub(crate) const TAG: &str = "::librqbit_bencode::RawValue";
|
||||
|
||||
impl<T> Serialize for RawValue<T>
|
||||
where
|
||||
T: AsRef<[u8]>,
|
||||
{
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
struct Wrapper<'a>(&'a [u8]);
|
||||
|
||||
impl<'a> Serialize for Wrapper<'a> {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_bytes(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
serializer.serialize_newtype_struct(TAG, &Wrapper(self.0.as_ref()))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue