This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use reqwest; | |
pub const AUTH_PATH : &str = "https://login.microsoftonline.com/1318d57f-757b-45b3-b1b0-9b3c3842774f/oauth2/authorize"; | |
pub const TOKEN_PATH : &str = "https://login.microsoftonline.com/1318d57f-757b-45b3-b1b0-9b3c3842774f/oauth2/token"; | |
pub const AUTH_RESOURCE_PATH : &str = "https://wegmans-es.azure-api.net"; | |
// Get a bearer token | |
pub fn authorize(client_id: &str, client_secret: &str, redirect_uri: &str) { | |
// build our request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"meta": { | |
"status": 200, | |
"msg": "OK" | |
}, | |
"response": { | |
"user": { // <== only care about this object | |
"name": "name", | |
"likes": 46310, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"user": { | |
"name": "doomy", | |
"likes": 46310, | |
"following": 242, | |
"default_post_format": "html", | |
"blogs": [ | |
{ | |
"admin": true, | |
"ask": true, | |
"ask_anon": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Representing JSON in Rust objects | |
All objects will always have an ID and Type, but all other fields vary | |
[ | |
{ | |
id: 12345, | |
type: "photo", | |
photo_url: "asdasda.com" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn set_voice_note_on(&mut self, note_data: NoteData){ | |
// loop over all available voices | |
for voice in &mut self.voices { | |
// check the `VoiceState` and find one that's off | |
if voice.state == VoiceState::Off { | |
// send a note to an unused voice. | |
voice.note_data = note_data; | |
// add our voice to our vector of used voice references | |
self.voices_in_use.push(voice); // <===== compiles if removed | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use asprim::AsPrim; | |
use vst2::buffer::AudioBuffer; | |
use vst2::api::Events; | |
use vst2::event::Event; | |
use num_traits::Float; | |
use voice::{Voice, VoiceState, Renderable}; | |
use utility::*; | |
use utility::note::{NoteData, NoteState}; | |
/// The base structure for handling voices, sounds, and processing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use asprim::AsPrim; | |
use vst2::buffer::AudioBuffer; | |
use vst2::api::Events; | |
use vst2::event::Event; | |
use num_traits::Float; | |
use voice::{Voice, VoiceState, Renderable}; | |
use utility::*; | |
use utility::note::{NoteData, NoteState}; | |
/// The base structure for handling voices, sounds, and processing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct MyStruct<'a> { | |
stuffs: Vec<&'a AnotherStruct> | |
} | |
pub struct AnotherStruct { | |
some_data: DataStruct | |
} | |
pub struct DataStruct { | |
number: i32, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn set_voice_note_off(&mut self, note_data: NoteData){ | |
for voice in &mut self.voices { | |
match voice.state { | |
// we only care if the note is currently on | |
VoiceState::On => { | |
// check if this voice is currently playing the note desired to be turned off | |
if voice.note_data.note == note_data.note { | |
// success - we found the voice to turn off | |
// replace the stored `voice.note_data` with our new `note_data` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<T> Default for MyStruct<T> where T: SomeTrait + Default { | |
fn default() -> Self { | |
MyStruct { some_field: SomeTrait::default() } // <-- error | |
} | |
} |